1. FilterTable
The FilterTable is a JTable subclass central to the framework.
// See FilterTableModel example
FilterTableModel<Person, String> tableModel = createFilterTableModel();
// Create the columns, specifying the identifier and the model index
List<FilterTableColumn<String>> columns = List.of(
FilterTableColumn.builder(Person.NAME, 0).build(),
FilterTableColumn.builder(Person.AGE, 1).build());
FilterTable<Person, String> table =
FilterTable.builder(tableModel, columns)
.doubleClick(Control.command(() ->
tableModel.selection().item().optional()
.ifPresent(System.out::println)))
.autoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS)
.build();
1.1. Columns
FilterTableColumnModel<String> columns = table.columnModel();
// Reorder the columns
columns.visible().set(Person.AGE, Person.NAME);
// Print hidden columns when they change
columns.hidden().addConsumer(System.out::println);
// Hide the age column
columns.visible(Person.AGE).set(false);
// Only show the age column
columns.visible().set(Person.AGE);
// Reset columns to their default location and visibility
columns.reset();
1.2. Search
FilterTableSearchModel search = table.search();
// Search for the value "43" in the table
search.predicate().set(value -> value.equals("43"));
RowColumn searchResult = search.results().current().get();
System.out.println(searchResult); // row: 1, column: 1
// Print the next available result
search.results().next().ifPresent(System.out::println);