RowFilter<TableModel, Object> firstFiler = null;Easy Huh?
RowFilter<TableModel, Object> secondFilter = null;
List<RowFilter<TableModel,Object>> filters = new ArrayList<RowFilter<TableModel,Object>>();
RowFilter<TableModel, Object> compoundRowFilter = null;
try {
firstFiler = RowFilter.regexFilter(yourRegexString, columnIndex);
secondFilter = RowFilter.regexFilter(yourRegexString, columnIndex);
filters.add(firstFiler);
filters.add(secondFilter);
compoundRowFilter = RowFilter.andFilter(filters); // you may also choose the OR filter
} catch (java.util.regex.PatternSyntaxException e) {
return;
}
sorter.setRowFilter(compoundRowFilter);
Showing posts with label jtable. Show all posts
Showing posts with label jtable. Show all posts
Saturday, June 12, 2010
Multiple Row Filters for JTable
When using the JTable from Java's swing UI, one might often come across a requirement when data filters need to be combined to offer results from searching multiple columns ... the Java Tutorials cover the simple stuff but they don't talk about combining filters! What to do? You can just hit the javadocs and put the pieces together OR after you've read the simple stuff, just try this and it should work like magic:
Subscribe to:
Posts (Atom)