Defining filter binders for tables

You can use a Text Filter Binder to filter the contents of a table that is bound to a data object.
The filter takes input from a text field, and it filters the table based on a particular property, or column, in the table. For example, if you have a JTable that lists all employees by last name and first name, you could use the input from a JTextField to filter the rows displayed in the JTable, using the last name column. Then, if you type characters in your filter input text field, only those employees whose last name includes those exact characters would display in the table. The following screen shot shows the sample results of a table being filtered using this mechanism:

Sample results of a table being filtered

When you define a Text Filter Binder, the visual editor generates the required interfaces and classes into the jve.generated package, and it creates a new instance of SwingPropertyFilter based on the properties that you define.

To configure a new filter binder for the contents of a table:

  1. Select the JTable that you want to filter. The table must already be bound to a data object.
  2. In the design view, right-click the table binder icon Object Table Binder icon for the JTable, and select Filter Binding Properties from the pop-up menu. The Filter Binding dialog opens.
  3. On the Filter Binding dialog, use the drop-down list to select the text field that you want to use for the filter's input. The drop-down lists all of the JTextField instances that are currently defined in your application.
  4. Select the table property that you want to use to filter the table. The list shows the properties in the data object bound to the table.

    Filter Binding dialog box

  5. Click OK.

Feedback