This is the code I have. It basically sorts the table based on what the user entered. The problem I have is i cannot retrieve the number of rows after the search. I have tried (rowSorter.getModel().getRowCount()); but it doesnt seem to work.
TableRowSorter<TableModel> rowSorter = new TableRowSorter(jTable.getModel());
jTable.setRowSorter(rowSorter);
String text = SearchTF.getText();
if (text.trim().length() == 0) {
rowSorter.setRowFilter(null);
} else {
rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
}
The TableRowSorter
will not affect the model, it generates a "proxy" of the model which the table can use to display the results.
Instead, ask the JTable
for the row count - See JTable#getRowCount