Research: I read a lot about listeners and firing updates and things. But I have read and reread them and still do not completely understand them. When I set a new model to the JTable, I actually want to KEEP my custom AbstractTableModel I created and just update the data, is this possible (maybe with public methods inside AbstractTableModel class that I can create)?
Yes it's possible. Basically, you need to either...
- Provide functionality in your custom table model to add and remove rows or
- Construct a new instance of the custom table model using the new data
Additional Questions: Should I be using a listener for this functionality? Do I need to add listeners or observers?
It's difficult to say without context. I would say, generally no. In your case it's probably simpler to create a SwingWorker
, perform the database query and either populate a new table model and return it from the doInBackground
method or use the publish
/process
methods to update the existing model.