FilterTablePanel

Top  Previous  Next

 

FilterTablePanel is a panel through which FilterModelEvents are created and propagated to FilterModelListeners. FilterTablePanel contains a collection of VisualFilters, one of each is shown at a time. The appropriate VisualFilter to use for a column is taken by calling the methods:

 

public VisualFilter getDefaultFilter(Class columnClass);

public VisualFilter getDefaultFilter(int field);

 

By default, FilterTablePanel installs visual filters for objects, strings, numbers and boolean values. This is done upon initialization with the method:

 

protected void createDefaultFilters();

 

You can construct a FilterTablePanel by using one of the constructors:

 

FilterTablePanel(String [] fields);

FilterTablePanel(String[] fields, Class[] classes);

FilterTablePanel(TableModel);

 

FilterTablePanel also includes a FilterModel object which is responsible for sending the events to the FilterModelListeners. FilterTableModel needs to be added to that list, so that it can receive the FilterModelEvents.

 

Example: Create a FilterTablePanel and use it to filter the data of a table.

 

//filteredModel is the FilterTableModel

 

//create the panel

FilterTablePanel filterPanel = new FilterTablePanel(filteredModel);

 

//add filteredModel to the list of FilterModeListeners

FilterModel filterModel = filterPanel.getFilterModel();

filterModel.addFilterModelListener(filteredModel);