TableView control, that can
be used as drop-in replacement control for the existing TableView, and provides
different functionalities and use cases.
TableView2 so that they
are always visible on screen.TableView2 so that
they are always visible on screen.FilteredTableView is a subclass of TableView2 with extended
filtering optionsColumnFixAction and RowFixAction. When fixed, the header's
background will show a darker color. For instance, these actions can be
attached to a ContextMenu that can be installed to the row header cells
with rowHeaderContextMenuFactory.
getFixedRows() and getFixedColumns(). But you
are strongly advised to check if it's possible to do so with
isColumnFixable(int) for the fixed columns and with
isRowFixable(int) for the fixed rows.
areRowsFixable(List) or
areTableViewColumnsFixable(List)
to verify if you can fix them.
Calling those methods prior every move will ensure that no exception will be thrown.
setRowHeaderVisible(boolean).
By default the row header will show the row index, but you can set the content
with setRowHeader(TableColumn).
TextField2TableCell and
ComboBox2TableCell, providing support for commit on focus lost.
FilteredTableView for extended filtering options.
Let's provide the underlying data model, based on a Person class.
public class Person {
private StringProperty firstName;
public void setFirstName(String value) { firstNameProperty().set(value); }
public String getFirstName() { return firstNameProperty().get(); }
public StringProperty firstNameProperty() {
if (firstName == null) firstName = new SimpleStringProperty(this, "firstName");
return firstName;
}
private StringProperty lastName;
public void setLastName(String value) { lastNameProperty().set(value); }
public String getLastName() { return lastNameProperty().get(); }
public StringProperty lastNameProperty() {
if (lastName == null) lastName = new SimpleStringProperty(this, "lastName");
return lastName;
}
}
A TableView2 can be created, and filled with an observable list of people:
TableView2<Person> table = new TableView2<Person>();
ObservableList<Person> people = getPeople();
table.setItems(people);
Now we add two columns to the table:
TableColumn2<Person,String> firstNameCol = new TableColumn2<>("First Name");
firstNameCol.setCellValueFactory(p -> p.getValue().firstNameProperty());
TableColumn2<Person,String> lastNameCol = new TableColumn2<>("Last Name");
lastNameCol.setCellValueFactory(p -> p.getValue().lastNameProperty());
table.getColumns().setAll(firstNameCol, lastNameCol);
A cell factory that allows commit on focus lost can be set:
firstName.setCellFactory(TextField2TableCell.forTableColumn());
We can fix some row and columns, and also show the row header:
table.getFixedColumns().setAll(firstNameColumn);
table.getFixedRows().setAll(0, 1, 2);
table.setRowHeaderVisible(true);
| Modifier and Type | Class and Description |
|---|---|
| public static enum | TableView2.
The SpanType describes in which state each cell can be.</center> |
| Modifier and Type | Field and Description |
|---|---|
| private final BooleanProperty | |
| private static final double | DEFAULT_ROW_HEADER_WIDTH
Default width of the VerticalHeader. |
| private final ObservableList | |
| private final ListChangeListener | |
| private final ObservableList | fixedRows
Private Fields * * |
| private final ListChangeListener | fixedRowsListener
********************************************************************* * private listeners ******************************************************************** |
| private BitSet | |
| private final BooleanProperty | |
| private final ObjectProperty | rowHeader
The row header property wraps a |
| private ObjectProperty | rowHeaderContextMenuFactory
An object property of a |
| private final BooleanProperty | |
| private final DoubleProperty | rowHeaderWidth
The vertical header width, just for the Label. |
| private final BooleanProperty | southHeaderBlended
This property allows the developer to blend the south table header row with the regular table header row, so for each column, the regular header and the south table column header look like a single one. |
| private String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | TableView2(ObservableList<S>
The items to insert into the TableView2, and the list to watch
for changes (to automatically show in the TableView2). items)Creates a TableView2 with the content provided in the items ObservableList. |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | Returns: true if the List of columns can be fixed together.list of column indices list)This method is the same as |
| public final boolean | Returns: true if the List of row can be fixed together.List of rows indices list)Indicates whether a List of rows can be fixed or not. |
| private boolean | Returns: true if the List of columns can be fixed together.list of list)TableColumnIndicates whether a List of |
| public final ReadOnlyBooleanProperty | Returns: the Boolean property associated with the allowance of fixing or unfixing some columns.Return the Boolean property associated with the allowance of fixing or unfixing some columns. |
| private String | |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public int | Returns: the current column span of a Cell.The pos)TablePositionReturn the current column span. |
| public final ObservableList | Returns: an ObservableList of the fixed columns.You can fix or unfix a column by modifying this list. |
| public final ObservableList | Returns: an ObservableList of integer representing the fixedRows.You can fix or unfix a row by modifying this list. |
| public final TableColumn | |
| public final BiFunction | |
| public final double | |
| public int | Returns: the current row span for the given cell.the pos, int TablePositionthe index index)Return the current row span at the given position in the Table. |
| public TableView2. | Returns: TheSpanType of a cellthe number of row rowIndex, final int the number of column modelColumn)Return the |
| public String | getUserAgentStylesheet()
Overrides javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. |
| private void | |
| public final boolean | Returns: true if the column if fixablethe number of column columnIndex)Indicate whether this column can be fixed or not. |
| public final boolean | Returns: whether changes to Fixed columns are enabled.Return whether changes to Fixed columns are enabled. |
| public final boolean | Returns: true if the row can be fixed.the number of row row)Indicate whether a row can be fixed or not. |
| public final boolean | Returns: whether changes to Fixed rows are enabled.Return whether changes to Fixed rows are enabled. |
| public final boolean | Returns: a boolean telling if the row header is being shownReturn if the row header is showing. |
| public final boolean | |
| public final ReadOnlyBooleanProperty | Returns: the Boolean property associated with the allowance of fixing or unfixing some rows.Return the Boolean property associated with the allowance of fixing or unfixing some rows. |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final BooleanProperty | Returns: the BooleanProperty associated with the row header.BooleanProperty associated with the row Header. |
| public final DoubleProperty | Returns: A DoubleProperty.This DoubleProperty represents the with of the rowHeader. |
| public final void | setColumnFixingEnabled(boolean
If set to true, user will be allowed to fix and unfix the columns b)If set to true, user will be allowed to fix and unfix the columns. |
| public final void | setRowFixingEnabled(boolean
If set to true, user will be allowed to fix and unfix the rows b)If set to true, user will be allowed to fix and unfix the rows. |
| public final void | |
| public final void | |
| public final void | setRowHeaderVisible(final boolean
boolean to show or hide the header b)Activate and deactivate the row header. |
| public final void | |
| public final void | |
| public void | sort()
Overrides javafx. Overrides |
| public final BooleanProperty |
| columnFixingEnabled | back to summary |
|---|---|
| private final BooleanProperty columnFixingEnabled | |
| DEFAULT_ROW_HEADER_WIDTH | back to summary |
|---|---|
| private static final double DEFAULT_ROW_HEADER_WIDTH Default width of the VerticalHeader. | |
| fixedColumns | back to summary |
|---|---|
| private final ObservableList<TableColumn<S, T>> fixedColumns | |
| fixedColumnsListener | back to summary |
|---|---|
| private final ListChangeListener<TableColumn<S, T>> fixedColumnsListener | |
| fixedRows | back to summary |
|---|---|
| private final ObservableList<Integer> fixedRows Private Fields * * | |
| fixedRowsListener | back to summary |
|---|---|
| private final ListChangeListener<Integer> fixedRowsListener ********************************************************************* * private listeners ******************************************************************** | |
| rowFix | back to summary |
|---|---|
| private BitSet rowFix | |
| rowFixingEnabled | back to summary |
|---|---|
| private final BooleanProperty rowFixingEnabled | |
| rowHeader | back to summary |
|---|---|
| private final ObjectProperty<TableColumn<S, ?>> rowHeader The row header property wraps a | |
| rowHeaderContextMenuFactory | back to summary |
|---|---|
| private ObjectProperty<BiFunction<Integer, S, ContextMenu>> rowHeaderContextMenuFactory An object property of a | |
| rowHeaderVisible | back to summary |
|---|---|
| private final BooleanProperty rowHeaderVisible | |
| rowHeaderWidth | back to summary |
|---|---|
| private final DoubleProperty rowHeaderWidth The vertical header width, just for the Label. | |
| southHeaderBlended | back to summary |
|---|---|
| private final BooleanProperty southHeaderBlended This property allows the developer to blend the south table header row with the regular table header row, so for each column, the regular header and the south table column header look like a single one. | |
| stylesheet | back to summary |
|---|---|
| private String stylesheet | |
| TableView2 | back to summary |
|---|---|
| public TableView2() Creates a TableView2 control with no content. | |
| TableView2 | back to summary |
|---|---|
| public TableView2(ObservableList<S> items) Creates a TableView2 with the content provided in the items ObservableList.
| |
| areColumnsFixable | back to summary |
|---|---|
| private boolean areColumnsFixable(List<? extends Integer> list) This method is the same as | |
| areRowsFixable | back to summary |
|---|---|
| public final boolean areRowsFixable(List<? extends Integer> list) Indicates whether a List of rows can be fixed or not. A set of rows cannot be fixed if any cell inside these rows has a row span superior to the number of fixed rows. | |
| areTableViewColumnsFixable | back to summary |
|---|---|
| private boolean areTableViewColumnsFixable(List<? extends TableColumn<S, T>> list) Indicates whether a List of
| |
| columnFixingEnabledProperty | back to summary |
|---|---|
| public final ReadOnlyBooleanProperty columnFixingEnabledProperty() Return the Boolean property associated with the allowance of fixing or unfixing some columns.
| |
| computeReason | back to summary |
|---|---|
| private String computeReason(List<? extends Integer> list) | |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. Create a new instance of the default skin for this control. This is called to create a skin for the control if
no skin is provided via CSS
| |
| getColumnSpan | back to summary |
|---|---|
| public int getColumnSpan(TablePosition<?, ?> pos) Return the current column span.
| |
| getFixedColumns | back to summary |
|---|---|
| public final ObservableList You can fix or unfix a column by modifying this list.
| |
| getFixedRows | back to summary |
|---|---|
| public final ObservableList You can fix or unfix a row by modifying this list. Call
| |
| getRowHeader | back to summary |
|---|---|
| public final TableColumn | |
| getRowHeaderContextMenuFactory | back to summary |
|---|---|
| public final BiFunction | |
| getRowHeaderWidth | back to summary |
|---|---|
public final double getRowHeaderWidth()
| |
| getRowSpan | back to summary |
|---|---|
| public int getRowSpan(TablePosition<?, ?> pos, int index) Return the current row span at the given position in the Table. If a sort is applied to the TableView2, some spanned cells may be splitted.
| |
| getSpanType | back to summary |
|---|---|
| public TableView2. Return the
| |
| getUserAgentStylesheet | back to summary |
|---|---|
| public String getUserAgentStylesheet() Overrides javafx. Doc from javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls. The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath. Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.
For additional information about using CSS with the scene graph,
see the CSS Reference Guide.
| |
| initRowFix | back to summary |
|---|---|
| private void initRowFix() Private/Protected Implementation * * | |
| isColumnFixable | back to summary |
|---|---|
| public final boolean isColumnFixable(int columnIndex) Indicate whether this column can be fixed or not.
| |
| isColumnFixingEnabled | back to summary |
|---|---|
| public final boolean isColumnFixingEnabled() Return whether changes to Fixed columns are enabled.
| |
| isRowFixable | back to summary |
|---|---|
| public final boolean isRowFixable(int row) Indicate whether a row can be fixed or not. Call that method before
adding an item with
| |
| isRowFixingEnabled | back to summary |
|---|---|
| public final boolean isRowFixingEnabled() Return whether changes to Fixed rows are enabled.
| |
| isRowHeaderVisible | back to summary |
|---|---|
| public final boolean isRowHeaderVisible() Return if the row header is showing.
| |
| isSouthHeaderBlended | back to summary |
|---|---|
| public final boolean isSouthHeaderBlended() | |
| rowFixingEnabledProperty | back to summary |
|---|---|
| public final ReadOnlyBooleanProperty rowFixingEnabledProperty() Return the Boolean property associated with the allowance of fixing or unfixing some rows.
| |
| rowHeaderContextMenuFactoryProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| rowHeaderProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| rowHeaderVisibleProperty | back to summary |
|---|---|
| public final BooleanProperty rowHeaderVisibleProperty() BooleanProperty associated with the row Header.
| |
| rowHeaderWidthProperty | back to summary |
|---|---|
| public final DoubleProperty rowHeaderWidthProperty() This DoubleProperty represents the with of the rowHeader. This is just representing the width of the Labels.
| |
| setColumnFixingEnabled | back to summary |
|---|---|
| public final void setColumnFixingEnabled(boolean b) If set to true, user will be allowed to fix and unfix the columns.
| |
| setRowFixingEnabled | back to summary |
|---|---|
| public final void setRowFixingEnabled(boolean b) If set to true, user will be allowed to fix and unfix the rows.
| |
| setRowHeader | back to summary |
|---|---|
| public final void setRowHeader(TableColumn<S, ?> value) | |
| setRowHeaderContextMenuFactory | back to summary |
|---|---|
| public final void setRowHeaderContextMenuFactory(BiFunction<Integer, S, ContextMenu> value) | |
| setRowHeaderVisible | back to summary |
|---|---|
| public final void setRowHeaderVisible(final boolean b) Activate and deactivate the row header.
| |
| setRowHeaderWidth | back to summary |
|---|---|
| public final void setRowHeaderWidth(double value) Specify a new width for the row header.
| |
| setSouthHeaderBlended | back to summary |
|---|---|
| public final void setSouthHeaderBlended(boolean value) | |
| sort | back to summary |
|---|---|
| public void sort() Overrides javafx. Overrides
| |
| southHeaderBlendedProperty | back to summary |
|---|---|
| public final BooleanProperty southHeaderBlendedProperty() | |
TableView2. Suppose you
have a cell spanning in row, the first one is in a ROW_VISIBLE state, and
all the other below are in a ROW_SPAN_INVISIBLE state. But if the user is
scrolling down, the first will go out of sight. At that moment, the
second cell is switching from ROW_SPAN_INVISIBLE state to ROW_VISIBLE
state. 
TableView2 for more information.
| Modifier and Type | Field and Description |
|---|---|
| public static final TableView2. | BOTH_INVISIBLE
Invisible cell situated in diagonal of a cell in a ROW_VISIBLE state. |
| public static final TableView2. | COLUMN_SPAN_INVISIBLE
Invisible cell because a cell in a NORMAL_CELL state on the left is covering it. |
| public static final TableView2. | NORMAL_CELL
Visible cell, can be a unique cell (no span) or the first one inside a column spanning cell. |
| public static final TableView2. | ROW_SPAN_INVISIBLE
Invisible cell because a cell in a ROW_VISIBLE state on the top is covering it. |
| public static final TableView2. | ROW_VISIBLE
Visible Cell but has some cells below in a ROW_SPAN_INVISIBLE state. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static TableView2. | |
| public static TableView2. |
| BOTH_INVISIBLE | back to summary |
|---|---|
| public static final TableView2. Invisible cell situated in diagonal of a cell in a ROW_VISIBLE state. | |
| COLUMN_SPAN_INVISIBLE | back to summary |
|---|---|
| public static final TableView2. Invisible cell because a cell in a NORMAL_CELL state on the left is covering it. | |
| NORMAL_CELL | back to summary |
|---|---|
| public static final TableView2. Visible cell, can be a unique cell (no span) or the first one inside a column spanning cell. | |
| ROW_SPAN_INVISIBLE | back to summary |
|---|---|
| public static final TableView2. Invisible cell because a cell in a ROW_VISIBLE state on the top is covering it. | |
| ROW_VISIBLE | back to summary |
|---|---|
| public static final TableView2. Visible Cell but has some cells below in a ROW_SPAN_INVISIBLE state. | |
| SpanType | back to summary |
|---|---|
| private SpanType() | |
| valueOf | back to summary |
|---|---|
| public static TableView2. | |
| values | back to summary |
|---|---|
| public static TableView2. | |