TableFilterHeader

TableFilterHeader is the main Gui component in the TableFilter library; it is a set of filter editors located just atop a table looking like in the figure below:

This header places together a set of filter editors, one per table's column, and is responsible to resize / move them as the table's columns change their layout.

It is also possible to place the component just below the table, although in this case we should probably better speak of a footer; it would look like:

The real value of this component relies on the filter editors used. The two figures above show the main available looks for those editors: as JTextField or JComboBox.

Basic usage

The TableFilterHeader class is placed in the package com.byteslooser.filters.gui

Setting up the TableFilterHeader requires two steps: including the GUI component in the global layout of the application, and attaching it to the associated table.

The header should be located just above or below the table. Placing it anywhere else misses the point of this component, as the columns will resize and move automatically as the user modifies the table columns layout. In this case, it is better to consider using the editors as standalone components.

An example of code setting up this component is:

JPane pane=new JPane(new BorderLayout());
JScrollPane scrollPane = new JScrollPane();
JTable table = new JTable();
TableFilterHeader filterHeader = new TableFilterHeader();
scrollPane.setViewportView(table);

pane.add(scrollPane, BorderLayout.CENTER);
pane.add(filterHeader, BorderLayout.NORTH);

Attaching now the filter header to the table is all that is needed to have a working filter

filterHeader.setTable(table);

Writing the previous code will use the default editor; the TableFilterHeader allows setting up its mode, which can be one of:

Setting up a different mode is as simple as writing:

filterHeader.setMode(TableFilterHeader.EditorMode.CHOICE);

Please note that each column could eventually use different editor types. In special, mixing the BASIC editor and the CHOICE can be in cases essential, to take advantage of the parsing capabilities of the former editor and the configuration possibilies of the later.

Advanced usage of the TableFilterHeader

The component is quite simple, its interface just tries to simplify the controlling of all the filter editors behind. The api documentation for this component describes its functionality.

The TableFilterHeader creates automatically filters of the defined mode, but it is possible to specify each column's editor separately. The following methods are the simples ways to create the library-defined editors:

It is also possible to create custom filter editors, setting them via the method setFilterEditor. In this case, the editor must implement the interface ITableFilterEditor

The figure below shows a test, supplied with source distribution of this library, showing all the included editors: