You shouldn't need to repaint the JList if you are updating the model, especially if your model calls fireContentsChanged(...)
after the new data has been added. Be sure to only change the model on the Swing event thread.
Consider that you
- Do the database query in a SwingWorker.
- Add a PropertyChangeListener to the SwingWorker
- When the SwingWorker's state property is changed to
SwingWorker.StateValue.DONE
, have the GUI get the new data from the SwingWorker and populate the ListModel on the EDT - And then have your ListModel fire its
fireContentChanged(...)
method. - The ListModel should extend AbstractListModel.
- Note that if you're able to use a DefaultListModel, you don't even have to call the
fireContent....()
method since the DefaultListModel will do that for you.