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.@IDProperty(value="id") public abstract class TableColumnBase<S,T> extends Object implements EventTarget, Styleable
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 |
---|---|
ObjectProperty<Comparator<T>> |
comparator
Comparator function used when sorting this table column.
|
ObjectProperty<ContextMenu> |
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.
|
ObjectProperty<Node> |
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.
|
ReadOnlyObjectProperty<TableColumnBase<S,?>> |
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 |
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.
|
ObjectProperty<Node> |
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 |
---|---|
static Comparator |
DEFAULT_COMPARATOR
By default all columns will use this comparator to perform sorting.
|
Modifier | Constructor and Description |
---|---|
protected |
TableColumnBase()
Creates a default TableColumn with default cell factory, comparator, and
onEditCommit implementation.
|
protected |
TableColumnBase(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(EventType<E> eventType,
EventHandler<E> eventHandler)
Registers an event handler to this table column.
|
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail)
Construct an event dispatch chain for this target.
|
ObjectProperty<Comparator<T>> |
comparatorProperty()
Comparator function used when sorting this table column.
|
ObjectProperty<ContextMenu> |
contextMenuProperty()
This menu will be shown whenever the user right clicks within the header
area of this TableColumnBase.
|
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 ObservableValue<T> |
getCellObservableValue(int index)
Attempts to return an ObservableValue<T> for the item in the given
index (which is of type S).
|
abstract ObservableValue<T> |
getCellObservableValue(S item)
Attempts to return an ObservableValue<T> for the given item (which
is of type S).
|
abstract ObservableList<? extends TableColumnBase<S,?>> |
getColumns()
This enables support for nested columns, which can be useful to group
together related data.
|
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.
|
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.
|
ObservableMap<Object,Object> |
getProperties()
Returns an observable map of properties on this table column for use
primarily by application developers.
|
ObservableSet<PseudoClass> |
getPseudoClassStates()
Return the pseudo-class state of this Styleable.
|
Node |
getSortNode()
Gets the value of the property sortNode.
|
String |
getStyle()
Gets the value of the property style.
|
ObservableList<String> |
getStyleClass()
A list of String identifiers which can be used to logically group
Nodes, specifically for an external style engine.
|
String |
getText()
Gets the value of the property text.
|
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.
|
ObjectProperty<Node> |
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 |
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.
|
ReadOnlyObjectProperty<TableColumnBase<S,?>> |
parentColumnProperty()
This read-only property will always refer to the parent of this column,
in the situation where nested columns are being used.
|
DoubleProperty |
prefWidthProperty()
The preferred width of the TableColumn.
|
<E extends Event> |
removeEventHandler(EventType<E> eventType,
EventHandler<E> eventHandler)
Unregisters a previously registered event handler from this table column.
|
BooleanProperty |
resizableProperty()
Used to indicate whether the width of this column can change.
|
void |
setComparator(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(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.
|
void |
setPrefWidth(double value)
Sets the value of the property prefWidth.
|
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(String value)
Sets the value of the property style.
|
void |
setText(String value)
Sets the value of the property text.
|
void |
setUserData(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.
|
BooleanProperty |
sortableProperty()
A boolean property to toggle on and off the 'sortability' of this column.
|
ObjectProperty<Node> |
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.
|
BooleanProperty |
visibleProperty()
Toggling this will immediately toggle the visibility of this column,
and all children columns.
|
ReadOnlyDoubleProperty |
widthProperty()
The width of this column.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCssMetaData, getStyleableParent, getTypeSelector
public final StringProperty textProperty
getText()
,
setText(String)
public final BooleanProperty visibleProperty
isVisible()
,
setVisible(boolean)
public final ReadOnlyObjectProperty<TableColumnBase<S,?>> 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 ObjectProperty<ContextMenu> 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 ObjectProperty<Node> 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 ObjectProperty<Node> 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 ObjectProperty<Comparator<T>> comparatorProperty
getComparator()
,
setComparator(Comparator)
public final BooleanProperty editableProperty
TableView.editableProperty()
and
TreeTableView.editableProperty()
, is true by default.isEditable()
,
setEditable(boolean)
public static final 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)
.protected TableColumnBase()
protected TableColumnBase(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(String value)
public final String getText()
public final void setVisible(boolean value)
public final boolean isVisible()
public final BooleanProperty visibleProperty()
isVisible()
,
setVisible(boolean)
public final TableColumnBase<S,?> getParentColumn()
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()
.
public final ReadOnlyObjectProperty<TableColumnBase<S,?>> 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 void setContextMenu(ContextMenu value)
public final ContextMenu getContextMenu()
public final ObjectProperty<ContextMenu> contextMenuProperty()
getContextMenu()
,
setContextMenu(ContextMenu)
public final void setId(String value)
null
.public final String getId()
public final StringProperty idProperty()
null
.getId()
,
setId(String)
public final void setStyle(String value)
Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
public final String getStyle()
getStyle
in interface Styleable
Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
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 ObservableList<String> getStyleClass()
getStyleClass
in interface Styleable
public final void setGraphic(Node value)
The graphic to show in the table column to allow the user to indicate graphically what is in the column.
public final Node getGraphic()
The graphic to show in the table column to allow the user to indicate graphically what is in the column.
public final ObjectProperty<Node> 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)
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.
public final Node getSortNode()
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.
public final ObjectProperty<Node> 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()
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)
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.
public final boolean isSortable()
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.
public final ObjectProperty<Comparator<T>> comparatorProperty()
getComparator()
,
setComparator(Comparator)
public final void setComparator(Comparator<T> value)
public final Comparator<T> getComparator()
public final void setEditable(boolean value)
TableView.editableProperty()
and
TreeTableView.editableProperty()
, is true by default.public final boolean isEditable()
TableView.editableProperty()
and
TreeTableView.editableProperty()
, is true by default.public final BooleanProperty editableProperty()
TableView.editableProperty()
and
TreeTableView.editableProperty()
, is true by default.isEditable()
,
setEditable(boolean)
public final ObservableMap<Object,Object> getProperties()
public boolean hasProperties()
public void setUserData(Object value)
getUserData()
.value
- The value to be stored - this can later be retrieved by calling
getUserData()
.public Object getUserData()
setUserData(java.lang.Object)
method.public abstract ObservableList<? extends TableColumnBase<S,?>> 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 ObservableValue<T> 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 ObservableValue<T> 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)
EventTarget
. This event target is
not automatically added to the chain, so if it wants to process events,
it needs to add an EventDispatcher
for itself to the chain.
In the case the event target is part of some hierarchy, the chain for it is usually built from event dispatchers collected from the root of the hierarchy to the event target.
The event dispatch chain is constructed by modifications to the provided initial event dispatch chain. The returned chain should have the initial chain at its end so the dispatchers should be prepended to the initial chain.
The caller shouldn't assume that the initial chain remains unchanged nor that the returned value will reference a different chain.
buildEventDispatchChain
in interface EventTarget
tail
- the initial chain to build frompublic <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<E> eventHandler)
eventType
- the type of the events to receive by the handlereventHandler
- the handler to registerNullPointerException
- if the event type or handler is nullpublic <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<E> eventHandler)
eventType
- the event type from which to unregistereventHandler
- the handler to unregisterNullPointerException
- if the event type or handler is nullpublic final ObservableSet<PseudoClass> getPseudoClassStates()
getPseudoClassStates
in interface Styleable
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.