JTable row filters updates
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开发者_StackOverflow社区 the correct way to do this?
thanks, Jeff
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 .
精彩评论