So I have a JTable filled with many elements and a TableRowSorter to sort the rows. This table has a "pulling" mode that checks for any changes from an outside source and updates the TableModel as necessary.
The problem is that the sorting causes the Table to flicker when the table is refreshing its contents. How can I make it so that the JTable does draw to screen until 1) the contents have been refreshed 2) these contents have been sorted?
I guess (this is what happens if you do not provide a SSCCE
) you have a table model based on DefaultTableModel
and adding the new contents in some sort of a loop using addRow
. Each call to addRow
in-turn invokes fireTableRowsInserted
. This is caught by the UI and the table is refreshed.
What you need to do is avoid the firing the event till all the rows are inserted. Override the insertRow
method from the model and remove the fire event. You can fire the event after all the rows are inserted.