Friday, 13 September 2013

Wants to get all rows from table. But returns searched rows only

Wants to get all rows from table. But returns searched rows only

This code is for sort the rows of JTable. I updates some values after sort
from the table. But I do some operation in this table, I got only searched
row count only. Not all rows.
public static void searchInTable(JTable table, JTextField text,
DefaultTableModel model, int column) {
TableRowSorter<DefaultTableModel> rowSorter = new
TableRowSorter<>(model);
table.setRowSorter(rowSorter);
String sortText = text.getText();
rowSorter.setRowFilter(RowFilter.regexFilter(sortText, column));
rowSorter.setSortKeys(null);
}

No comments:

Post a Comment