views:

143

answers:

1

Is there a way to tell a JTable's row filter that it should update itself to display the filtered data? I'm currently using the fireTableDataChanged method in the AbstractTableModel but the underlying data for the table isn't actually changing, so this seems like it might be wasteful. The way my filter works is to check if data in the table is in some other list and only display it if it is in that list. So that other list changed and I need to tell the filter to refresh itself. Is fireTableDataChanged the correct way to do this?

thanks, Jeff

+2  A: 

fireTableDataChanged IS a correct way to do it.

I would consider the "other list" a part of your data. That means it should be a part of your table model. So whenever it changes the model should call fireTableDataChanged. This will do the trick.

If you cannot make it a part of your model it at least should notify the model when change happened and then model will call fireTableDataChanged. For notification you can use standard listeners approach or if you prefer global approach Event Bus framework can be of help .

eugener
good explanation, thanks.
Jeff Storey