-
Notifications
You must be signed in to change notification settings - Fork 65
Table Filtering
Starting with Java 6 any JTable can be decorated with row filter UI based on RowFilter.
All classes can be found in the org.oxbow.swingbits.table.filter package
Existing table can be decorated as:
JTable table = new JTable();
TableRowFilterSupport.forTable(table).apply();or it can be done in one line together with JTable creation:
JTable table = TableRowFilterSupport
.forTable(new JTable())
.apply();The table will aquire Excel-like filtering UI such as:

Search in column popup can be enabled also:
JTable table = TableRowFilterSupport
.forTable(new JTable())
.searchable(true)
.apply();
If default search using toString method is not satisfactory then custom 'object to string' translator can be added.
In certain cases (like older versions of JXTable from SwingX library) default RowFilter based filtering will not work. This can be solved by custom implementation of ITableFilter. Such an implementation is shown here. In this case the signature of using TableRowFilterSupport will look slightly different:
JTable table = TableRowFilterSupport
.forFilter(new JXTableFilter(new JXTable()))
.searchable(true)
.apply();Since version 0.0.3 check list shows actions on top of check items by default. Currently only one action ("(All)" is available with the plan to add more standard ones and provide the ability to create custom ones.

It is possible to hide the actions:
JTable table = TableRowFilterSupport
.forTable(new JTable())
.searchable(true)
.actions(false)
.apply();