I have a JTable with four columns, the first of which contains either a number or text, the remaining three texts. I am trying to filter this table with a RowFilter:
sorter = new TableRowSorter<TableModel>(myOwnTableModel);
checkboxFilter I got pretty good work:
sorter.setRowFilter(RowFilter.regexFilter("^[0-9]$", 0));
This sorter is activated or deactivated depending on the checkbox selected or not checked.
The second filtering occurs if the user places the text in a text field. For myself, this already works great:
String regex = "(?i)" + Pattern.quote(s);
sorter.setRowFilter(RowFilter.regexFilter(regex, 1,2,3));
What I cannot do is activate both filters at the same time. Perhaps Iβm thinking too much, my idea was to "concatenate" two filters, the Filter should be "and" another "or" checkbox. I tried several things, for me something like the most promising looked:
String regex = "(?i)" + Pattern.quote(s);
bookFilter = RowFilter.regexFilter(regex, 1,2,3);
sorter.setRowFilter(bookFilter.andFilter(Arrays.asList(
RowFilter.regexFilter("^[0-9]$", 0))));
Unfortunately, this does not lead to a useful result. Any ideas appreciated :)
source
share