JTable Filtering and getting filtered data in text file [closed]

I have a jtable(20 columns) with an abstract model(40 columns). I want to add filter for jtable’s 15th column. How can i do that? I have searched and tried many options like RowFilter.regexFilter(text, index); but they didn’t worked. They add filter by searching the whole table but i want to filter table based on 1 column’s data.

Secondly after the filter is added, how i can get that filtered data in a .txt file? Not the file writing stuff; but getting data from model based on that filter applied above.

Thanks in advance.

Answer

but getting data from model based on that filter applied above.

You don’t get the data from the model because the model still contain all the data. You need to get the data from the table since the table is display the currently filtered data. For this you just create a loop through all the row/column in the table and use:

table.getValueAt(row, column);

Leave a Reply

Your email address will not be published. Required fields are marked *