S
- The type of the UI control (e.g. the type of the 'row').T
- The type of the content in all cells in this table column.public abstract class TableColumnBase<S,T>
extends java.lang.Object
TableView
and TreeTableView
) are
made up of zero or more instances of a concrete TableColumnBase subclass
(TableColumn
and TreeTableColumn
, respectively). Each
table column in a table is responsible for displaying (and editing) the contents
of that column. As well as being responsible for displaying and editing data
for a single column, a table column also contains the necessary properties to:
minWidth
/prefWidth
/maxWidth
and width
properties)
visibility
toggled
header text
nested columns
it may contain
context menu
when the user
right-clicks the column header area
comparator
, sortable
and
sortType).
text
(what to show in the column header area), and the column
cell value factory
(which is used to populate individual cells in the
column). Refer to the class documentation for TableColumn
and
TreeTableColumn
for more information.TableColumn
,
TreeTableColumn
,
TablePositionBase
Type | Property and Description |
---|---|
<any> |
comparator
Comparator function used when sorting this table column.
|
<any> |
contextMenu
This menu will be shown whenever the user right clicks within the header
area of this TableColumnBase.
|
BooleanProperty |
editable
Specifies whether this table column allows editing.
|
<any> |
graphic
The graphic to show in the table column to allow the user to
indicate graphically what is in the column.
|
StringProperty |
id
The id of this TableColumnBase.
|
DoubleProperty |
maxWidth
The maximum width the table column is permitted to be resized to.
|
DoubleProperty |
minWidth
The minimum width the table column is permitted to be resized to.
|
<any> |
parentColumn
This read-only property will always refer to the parent of this column,
in the situation where nested columns are being used.
|
DoubleProperty |
prefWidth
The preferred width of the TableColumn.
|
BooleanProperty |
reorderable
A boolean property to toggle on and off the 'reorderability' of this column
(with drag and drop - reordering by modifying the appropriate
columns
list is always allowed). |
BooleanProperty |
resizable
Used to indicate whether the width of this column can change.
|
BooleanProperty |
sortable
A boolean property to toggle on and off the 'sortability' of this column.
|
<any> |
sortNode
The node to use as the "sort arrow", shown to the user in situations where
the table column is part of the sort order.
|
StringProperty |
style
A string representation of the CSS style associated with this
TableColumnBase instance.
|
StringProperty |
text
This is the text to show in the header for this column.
|
BooleanProperty |
visible
Toggling this will immediately toggle the visibility of this column,
and all children columns.
|
ReadOnlyDoubleProperty |
width
The width of this column.
|
Modifier and Type | Field and Description |
---|---|
private <any> |
comparator
Comparator function used when sorting this table column.
|
private <any> |
contextMenu
This menu will be shown whenever the user right clicks within the header
area of this TableColumnBase.
|
static java.util.Comparator |
DEFAULT_COMPARATOR
By default all columns will use this comparator to perform sorting.
|
(package private) static double |
DEFAULT_MAX_WIDTH |
(package private) static double |
DEFAULT_MIN_WIDTH |
(package private) static double |
DEFAULT_WIDTH
*
Static properties and methods *
*
|
private BooleanProperty |
editable
Specifies whether this table column allows editing.
|
(package private) EventHandlerManager |
eventHandlerManager
*
Instance Variables *
*
|
private <any> |
graphic
The graphic to show in the table column to allow the user to
indicate graphically what is in the column.
|
private StringProperty |
id
The id of this TableColumnBase.
|
private DoubleProperty |
maxWidth |
private DoubleProperty |
minWidth
The minimum width the table column is permitted to be resized to.
|
private <any> |
parentColumn
This read-only property will always refer to the parent of this column,
in the situation where nested columns are being used.
|
private DoubleProperty |
prefWidth |
private <any> |
properties |
private BooleanProperty |
reorderable
A boolean property to toggle on and off the 'reorderability' of this column
(with drag and drop - reordering by modifying the appropriate
columns
list is always allowed). |
private BooleanProperty |
resizable
Used to indicate whether the width of this column can change.
|
private BooleanProperty |
sortable
A boolean property to toggle on and off the 'sortability' of this column.
|
private <any> |
sortNode
The node to use as the "sort arrow", shown to the user in situations where
the table column is part of the sort order.
|
private StringProperty |
style
A string representation of the CSS style associated with this
TableColumnBase instance.
|
private <any> |
styleClass |
private StringProperty |
text
This is the text to show in the header for this column.
|
private static java.lang.Object |
USER_DATA_KEY |
private BooleanProperty |
visible
Toggling this will immediately toggle the visibility of this column,
and all children columns.
|
private ReadOnlyDoubleWrapper |
width |
Modifier | Constructor and Description |
---|---|
protected |
TableColumnBase()
Creates a default TableColumn with default cell factory, comparator, and
onEditCommit implementation.
|
protected |
TableColumnBase(java.lang.String text)
Creates a TableColumn with the text set to the provided string, with
default cell factory, comparator, and onEditCommit implementation.
|
Modifier and Type | Method and Description |
---|---|
<E extends Event> |
addEventHandler(<any> eventType,
<any> eventHandler)
Registers an event handler to this table column.
|
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail) |
<any> |
comparatorProperty()
Comparator function used when sorting this table column.
|
<any> |
contextMenuProperty()
This menu will be shown whenever the user right clicks within the header
area of this TableColumnBase.
|
(package private) void |
doSetWidth(double width)
*
Private Implementation *
*
|
BooleanProperty |
editableProperty()
Specifies whether this table column allows editing.
|
T |
getCellData(int index)
Returns the actual value for a cell at a given row index (and which
belongs to this table column).
|
T |
getCellData(S item)
Returns the actual value for a cell from the given item.
|
abstract <any> |
getCellObservableValue(int index)
Attempts to return an ObservableValue<T> for the item in the given
index (which is of type S).
|
abstract <any> |
getCellObservableValue(S item)
Attempts to return an ObservableValue<T> for the given item (which
is of type S).
|
abstract <any> |
getColumns()
This enables support for nested columns, which can be useful to group
together related data.
|
java.util.Comparator<T> |
getComparator()
Gets the value of the property comparator.
|
ContextMenu |
getContextMenu()
Gets the value of the property contextMenu.
|
Node |
getGraphic()
Gets the value of the property graphic.
|
java.lang.String |
getId()
Gets the value of the property id.
|
double |
getMaxWidth()
Gets the value of the property maxWidth.
|
double |
getMinWidth()
Gets the value of the property minWidth.
|
TableColumnBase<S,?> |
getParentColumn()
Gets the value of the property parentColumn.
|
double |
getPrefWidth()
Gets the value of the property prefWidth.
|
<any> |
getProperties()
Returns an observable map of properties on this table column for use
primarily by application developers.
|
<any> |
getPseudoClassStates() |
Node |
getSortNode()
Gets the value of the property sortNode.
|
java.lang.String |
getStyle()
Gets the value of the property style.
|
<any> |
getStyleClass()
A list of String identifiers which can be used to logically group
Nodes, specifically for an external style engine.
|
java.lang.String |
getText()
Gets the value of the property text.
|
java.lang.Object |
getUserData()
Returns a previously set Object property, or null if no such property
has been set using the
setUserData(java.lang.Object) method. |
double |
getWidth()
Gets the value of the property width.
|
<any> |
graphicProperty()
The graphic to show in the table column to allow the user to
indicate graphically what is in the column.
|
boolean |
hasProperties()
Tests if this table column has properties.
|
StringProperty |
idProperty()
The id of this TableColumnBase.
|
boolean |
isEditable()
Gets the value of the property editable.
|
boolean |
isReorderable()
Gets the value of the property reorderable.
|
boolean |
isResizable()
Gets the value of the property resizable.
|
boolean |
isSortable()
Gets the value of the property sortable.
|
boolean |
isVisible()
Gets the value of the property visible.
|
DoubleProperty |
maxWidthProperty()
The maximum width the table column is permitted to be resized to.
|
DoubleProperty |
minWidthProperty()
The minimum width the table column is permitted to be resized to.
|
<any> |
parentColumnProperty()
This read-only property will always refer to the parent of this column,
in the situation where nested columns are being used.
|
private <any> |
parentColumnPropertyImpl() |
DoubleProperty |
prefWidthProperty()
The preferred width of the TableColumn.
|
<E extends Event> |
removeEventHandler(<any> eventType,
<any> eventHandler)
Unregisters a previously registered event handler from this table column.
|
BooleanProperty |
reorderableProperty()
A boolean property to toggle on and off the 'reorderability' of this column
(with drag and drop - reordering by modifying the appropriate
columns
list is always allowed). |
BooleanProperty |
resizableProperty()
Used to indicate whether the width of this column can change.
|
void |
setComparator(java.util.Comparator<T> value)
Sets the value of the property comparator.
|
void |
setContextMenu(ContextMenu value)
Sets the value of the property contextMenu.
|
void |
setEditable(boolean value)
Sets the value of the property editable.
|
void |
setGraphic(Node value)
Sets the value of the property graphic.
|
void |
setId(java.lang.String value)
Sets the value of the property id.
|
void |
setMaxWidth(double value)
Sets the value of the property maxWidth.
|
void |
setMinWidth(double value)
Sets the value of the property minWidth.
|
(package private) void |
setParentColumn(TableColumnBase<S,?> value) |
void |
setPrefWidth(double value)
Sets the value of the property prefWidth.
|
void |
setReorderable(boolean value)
Sets the value of the property reorderable.
|
void |
setResizable(boolean value)
Sets the value of the property resizable.
|
void |
setSortable(boolean value)
Sets the value of the property sortable.
|
void |
setSortNode(Node value)
Sets the value of the property sortNode.
|
void |
setStyle(java.lang.String value)
Sets the value of the property style.
|
void |
setText(java.lang.String value)
Sets the value of the property text.
|
void |
setUserData(java.lang.Object value)
Convenience method for setting a single Object property that can be
retrieved at a later date.
|
void |
setVisible(boolean value)
Sets the value of the property visible.
|
(package private) void |
setWidth(double value) |
BooleanProperty |
sortableProperty()
A boolean property to toggle on and off the 'sortability' of this column.
|
<any> |
sortNodeProperty()
The node to use as the "sort arrow", shown to the user in situations where
the table column is part of the sort order.
|
StringProperty |
styleProperty()
A string representation of the CSS style associated with this
TableColumnBase instance.
|
StringProperty |
textProperty()
This is the text to show in the header for this column.
|
(package private) void |
updateColumnWidths() |
BooleanProperty |
visibleProperty()
Toggling this will immediately toggle the visibility of this column,
and all children columns.
|
ReadOnlyDoubleProperty |
widthProperty()
The width of this column.
|
public final StringProperty textProperty
getText()
,
setText(String)
public final BooleanProperty visibleProperty
isVisible()
,
setVisible(boolean)
public final <any> parentColumnProperty
In the currently existing subclasses, to create a nested
column is simply a matter of placing the relevant TableColumnBase instances
inside the columns ObservableList (for example, see
TableColumn.getColumns()
and
TreeTableColumn.getColumns()
.
getParentColumn()
public final <any> contextMenuProperty
getContextMenu()
,
setContextMenu(ContextMenu)
public final StringProperty idProperty
null
.getId()
,
setId(String)
public final StringProperty styleProperty
Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
getStyle()
,
setStyle(String)
public final <any> graphicProperty
The graphic to show in the table column to allow the user to indicate graphically what is in the column.
getGraphic()
,
setGraphic(Node)
public final <any> sortNodeProperty
The node to use as the "sort arrow", shown to the user in situations where
the table column is part of the sort order. It may be the only item in
the sort order, or it may be a secondary, tertiary, or latter sort item,
and the node should reflect this visually. This is only used in the case of
the table column being in the sort order (refer to, for example,
TableView.getSortOrder()
and TreeTableView.getSortOrder()
).
If not specified, the table column skin implementation is responsible for
providing a default sort node.
The sort node is commonly seen represented as a triangle that rotates on screen to indicate whether the table column is part of the sort order, and if so, whether the sort is ascending or descending, and what position in the sort order it is in.
getSortNode()
,
setSortNode(Node)
public final ReadOnlyDoubleProperty widthProperty
getWidth()
public final DoubleProperty minWidthProperty
getMinWidth()
,
setMinWidth(double)
public final DoubleProperty prefWidthProperty
getPrefWidth()
,
setPrefWidth(double)
public final DoubleProperty maxWidthProperty
getMaxWidth()
,
setMaxWidth(double)
public final BooleanProperty resizableProperty
isResizable()
,
setResizable(boolean)
public final BooleanProperty sortableProperty
A boolean property to toggle on and off the 'sortability' of this column.
When this property is true, this column can be included in sort
operations. If this property is false, it will not be included in sort
operations, even if it is contained within the sort order list of the
underlying UI control (e.g. TableView.getSortOrder()
or
TreeTableView.getSortOrder()
).
For example, iIf a TableColumn instance is contained within the TableView sortOrder ObservableList, and its sortable property toggles state, it will force the TableView to perform a sort, as it is likely the view will need updating.
isSortable()
,
setSortable(boolean)
public final BooleanProperty reorderableProperty
columns
list is always allowed). When this property is true, this column can be reordered by
users simply by dragging and dropping the columns into their desired positions.
When this property is false, this ability to drag and drop columns is not available.isReorderable()
,
setReorderable(boolean)
public final <any> comparatorProperty
getComparator()
,
setComparator(Comparator)
public final BooleanProperty editableProperty
TableView.editableProperty()
and
TreeTableView.editableProperty()
, is true by default.isEditable()
,
setEditable(boolean)
static final double DEFAULT_WIDTH
static final double DEFAULT_MIN_WIDTH
static final double DEFAULT_MAX_WIDTH
public static final java.util.Comparator DEFAULT_COMPARATOR
Comparable
. If it is, the Comparable.compareTo(java.lang.Object)
method is called, otherwise this method will defer to
Collator.compare(java.lang.String, java.lang.String)
.final EventHandlerManager eventHandlerManager
private StringProperty text
private BooleanProperty visible
private <any> parentColumn
In the currently existing subclasses, to create a nested
column is simply a matter of placing the relevant TableColumnBase instances
inside the columns ObservableList (for example, see
TableColumn.getColumns()
and
TreeTableColumn.getColumns()
.
private <any> contextMenu
private StringProperty id
null
.private StringProperty style
Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
private final <any> styleClass
private <any> graphic
The graphic to show in the table column to allow the user to indicate graphically what is in the column.
private <any> sortNode
The node to use as the "sort arrow", shown to the user in situations where
the table column is part of the sort order. It may be the only item in
the sort order, or it may be a secondary, tertiary, or latter sort item,
and the node should reflect this visually. This is only used in the case of
the table column being in the sort order (refer to, for example,
TableView.getSortOrder()
and TreeTableView.getSortOrder()
).
If not specified, the table column skin implementation is responsible for
providing a default sort node.
The sort node is commonly seen represented as a triangle that rotates on screen to indicate whether the table column is part of the sort order, and if so, whether the sort is ascending or descending, and what position in the sort order it is in.
private ReadOnlyDoubleWrapper width
private DoubleProperty minWidth
private final DoubleProperty prefWidth
private DoubleProperty maxWidth
private BooleanProperty resizable
private BooleanProperty sortable
A boolean property to toggle on and off the 'sortability' of this column.
When this property is true, this column can be included in sort
operations. If this property is false, it will not be included in sort
operations, even if it is contained within the sort order list of the
underlying UI control (e.g. TableView.getSortOrder()
or
TreeTableView.getSortOrder()
).
For example, iIf a TableColumn instance is contained within the TableView sortOrder ObservableList, and its sortable property toggles state, it will force the TableView to perform a sort, as it is likely the view will need updating.
private BooleanProperty reorderable
columns
list is always allowed). When this property is true, this column can be reordered by
users simply by dragging and dropping the columns into their desired positions.
When this property is false, this ability to drag and drop columns is not available.private <any> comparator
private BooleanProperty editable
TableView.editableProperty()
and
TreeTableView.editableProperty()
, is true by default.private static final java.lang.Object USER_DATA_KEY
private <any> properties
protected TableColumnBase()
protected TableColumnBase(java.lang.String text)
text
- The string to show when the TableColumn is placed within the TableView.public final StringProperty textProperty()
getText()
,
setText(String)
public final void setText(java.lang.String value)
public final java.lang.String getText()
public final void setVisible(boolean value)
public final boolean isVisible()
public final BooleanProperty visibleProperty()
isVisible()
,
setVisible(boolean)
void setParentColumn(TableColumnBase<S,?> value)
public final TableColumnBase<S,?> getParentColumn()
public final <any> parentColumnProperty()
In the currently existing subclasses, to create a nested
column is simply a matter of placing the relevant TableColumnBase instances
inside the columns ObservableList (for example, see
TableColumn.getColumns()
and
TreeTableColumn.getColumns()
.
getParentColumn()
private <any> parentColumnPropertyImpl()
public final void setContextMenu(ContextMenu value)
public final ContextMenu getContextMenu()
public final <any> contextMenuProperty()
getContextMenu()
,
setContextMenu(ContextMenu)
public final void setId(java.lang.String value)
public final java.lang.String getId()
public final StringProperty idProperty()
null
.getId()
,
setId(String)
public final void setStyle(java.lang.String value)
public final java.lang.String getStyle()
public final StringProperty styleProperty()
Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
getStyle()
,
setStyle(String)
public <any> getStyleClass()
public final void setGraphic(Node value)
public final Node getGraphic()
public final <any> graphicProperty()
The graphic to show in the table column to allow the user to indicate graphically what is in the column.
getGraphic()
,
setGraphic(Node)
public final void setSortNode(Node value)
public final Node getSortNode()
public final <any> sortNodeProperty()
The node to use as the "sort arrow", shown to the user in situations where
the table column is part of the sort order. It may be the only item in
the sort order, or it may be a secondary, tertiary, or latter sort item,
and the node should reflect this visually. This is only used in the case of
the table column being in the sort order (refer to, for example,
TableView.getSortOrder()
and TreeTableView.getSortOrder()
).
If not specified, the table column skin implementation is responsible for
providing a default sort node.
The sort node is commonly seen represented as a triangle that rotates on screen to indicate whether the table column is part of the sort order, and if so, whether the sort is ascending or descending, and what position in the sort order it is in.
getSortNode()
,
setSortNode(Node)
public final ReadOnlyDoubleProperty widthProperty()
getWidth()
public final double getWidth()
void setWidth(double value)
public final void setMinWidth(double value)
public final double getMinWidth()
public final DoubleProperty minWidthProperty()
getMinWidth()
,
setMinWidth(double)
public final DoubleProperty prefWidthProperty()
getPrefWidth()
,
setPrefWidth(double)
public final void setPrefWidth(double value)
public final double getPrefWidth()
public final DoubleProperty maxWidthProperty()
getMaxWidth()
,
setMaxWidth(double)
public final void setMaxWidth(double value)
public final double getMaxWidth()
public final BooleanProperty resizableProperty()
isResizable()
,
setResizable(boolean)
public final void setResizable(boolean value)
public final boolean isResizable()
public final BooleanProperty sortableProperty()
A boolean property to toggle on and off the 'sortability' of this column.
When this property is true, this column can be included in sort
operations. If this property is false, it will not be included in sort
operations, even if it is contained within the sort order list of the
underlying UI control (e.g. TableView.getSortOrder()
or
TreeTableView.getSortOrder()
).
For example, iIf a TableColumn instance is contained within the TableView sortOrder ObservableList, and its sortable property toggles state, it will force the TableView to perform a sort, as it is likely the view will need updating.
isSortable()
,
setSortable(boolean)
public final void setSortable(boolean value)
public final boolean isSortable()
public final BooleanProperty reorderableProperty()
columns
list is always allowed). When this property is true, this column can be reordered by
users simply by dragging and dropping the columns into their desired positions.
When this property is false, this ability to drag and drop columns is not available.isReorderable()
,
setReorderable(boolean)
public final void setReorderable(boolean value)
public final boolean isReorderable()
public final <any> comparatorProperty()
getComparator()
,
setComparator(Comparator)
public final void setComparator(java.util.Comparator<T> value)
public final java.util.Comparator<T> getComparator()
public final void setEditable(boolean value)
public final boolean isEditable()
public final BooleanProperty editableProperty()
TableView.editableProperty()
and
TreeTableView.editableProperty()
, is true by default.isEditable()
,
setEditable(boolean)
public final <any> getProperties()
public boolean hasProperties()
public void setUserData(java.lang.Object value)
getUserData()
.value
- The value to be stored - this can later be retrieved by calling
getUserData()
.public java.lang.Object getUserData()
setUserData(java.lang.Object)
method.public abstract <any> getColumns()
This has no impact on the table as such - all column indices point to the leaf columns only, and it isn't possible to sort using the parent column, just the leaf columns. In other words, this is purely a visual feature.
public final T getCellData(int index)
index
- The row index for which the data is required.public final T getCellData(S item)
item
- The item from which a value of type T should be extracted.public abstract <any> getCellObservableValue(int index)
This is achieved by calling the cell value factory
, and
returning whatever it returns when passed a CellDataFeatures
(see,
for example, the CellDataFeatures classes belonging to
TableColumn
and
TreeTableColumn
for more
information).
index
- The index of the item (of type S) for which an
ObservableValue<T> is sought.public abstract <any> getCellObservableValue(S item)
This is achieved by calling the cell value factory
, and
returning whatever it returns when passed a CellDataFeatures
(see,
for example, the CellDataFeatures classes belonging to
TableColumn
and
TreeTableColumn
for more
information).
item
- The item (of type S) for which an ObservableValue<T> is
sought.public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail)
public <E extends Event> void addEventHandler(<any> eventType, <any> eventHandler)
E
- The type of eventeventType
- the type of the events to receive by the handlereventHandler
- the handler to registerjava.lang.NullPointerException
- if the event type or handler is nullpublic <E extends Event> void removeEventHandler(<any> eventType, <any> eventHandler)
E
- The type of eventeventType
- the event type from which to unregistereventHandler
- the handler to unregisterjava.lang.NullPointerException
- if the event type or handler is nullvoid doSetWidth(double width)
void updateColumnWidths()
public final <any> getPseudoClassStates()