Spec-Zone .ru
спецификации, руководства, описания, API
|
S
- The type of the TableView generic type (i.e. S == TableView<S>)T
- The type of the content in all cells in this TableColumn.public class TableColumn<S,T> extends java.lang.Object implements EventTarget
TableView
is made up of a number of TableColumn instances. Each
TableColumn 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 TableColumn 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). This can be
achieved using some variation on the following code:
ObservableList<Person> data = ...
TableView<Person> tableView = new TableView<Person>(data);
TableColumn<Person,String> firstNameCol = new TableColumn<Person,String>("First Name");
firstNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
// p.getValue() returns the Person instance for a particular TableView row
return p.getValue().firstNameProperty();
}
});
tableView.getColumns().add(firstNameCol);}
This approach assumes that the object returned from p.getValue()
has a JavaFX ObservableValue
that can simply be returned. The benefit of this
is that the TableView will internally create bindings to ensure that,
should the returned ObservableValue
change, the cell contents will be
automatically refreshed.
In situations where a TableColumn must interact with classes created before
JavaFX, or that generally do not wish to use JavaFX apis for properties, it is
possible to wrap the returned value in a ReadOnlyObjectWrapper
instance. For
example:
firstNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
return new ReadOnlyObjectWrapper(p.getValue().getFirstName());
}
});
It is hoped that over time there will be convenience cell value factories
developed and made available to developers. As of the JavaFX 2.0 release,
there is one such convenience class: PropertyValueFactory
. This class
removes the need to write the code above, instead relying on reflection to
look up a given property from a String. Refer to the
PropertyValueFactory
class documentation for more information
on how to use this with a TableColumn.
Finally, for more detail on how to use TableColumn, there is further documentation in
the TableView
class documentation.TableView
,
TableCell
,
TablePosition
Type | Property and Description |
---|---|
ObjectProperty<Callback<TableColumn<S,T>,TableCell<S,T>>> |
cellFactory
The cell factory for all cells in this column.
|
ObjectProperty<Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>>> |
cellValueFactory
The cell value factory needs to be set to specify how to populate all
cells within a single TableColumn.
|
ObjectProperty<java.util.Comparator<T>> |
comparator
Comparator function used when sorting this TableColumn.
|
ObjectProperty<ContextMenu> |
contextMenu
This menu will be shown whenever the user right clicks within the header
area of this TableColumn.
|
BooleanProperty |
editable
Specifies whether this TableColumn allows editing.
|
ObjectProperty<Node> |
graphic
The graphic in the TableColumn.
|
StringProperty |
id
The id of this TableColumn.
|
DoubleProperty |
maxWidth
The maximum width the TableColumn is permitted to be resized to.
|
DoubleProperty |
minWidth
The minimum width the TableColumn is permitted to be resized to.
|
ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> |
onEditCancel
This event handler will be fired when the user cancels editing a cell.
|
ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> |
onEditCommit
This event handler will be fired when the user successfully commits their
editing.
|
ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> |
onEditStart
This event handler will be fired when the user successfully initiates
editing.
|
ReadOnlyObjectProperty<TableColumn<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 sort node is commonly seen represented as a triangle that rotates
on screen to indicate whether the TableColumn is part of the sort order,
and if so, what position in the sort order it is in.
|
ObjectProperty<TableColumn.SortType> |
sortType
Used to state whether this column, if it is part of the
TableView.sortOrder ObservableList, should be sorted in ascending
or descending order. |
StringProperty |
style
The CSS style string associated to this TableColumn.
|
ReadOnlyObjectProperty<TableView<S>> |
tableView
The TableView that this TableColumn belongs to.
|
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 | Class and Description |
---|---|
static class |
TableColumn.CellDataFeatures<S,T>
A support class used in TableColumn as a wrapper class
to provide all necessary information for a particular
Cell . |
static class |
TableColumn.CellEditEvent<S,T>
An event that is fired when a user performs an edit on a table cell.
|
static class |
TableColumn.SortType
Enumeration that specifies the type of sorting being applied to a specific
column.
|
Modifier and Type | Field and Description |
---|---|
static Callback<TableColumn<?,?>,TableCell<?,?>> |
DEFAULT_CELL_FACTORY
If no cellFactory is specified on a TableColumn instance, then this one
will be used by default.
|
static java.util.Comparator |
DEFAULT_COMPARATOR
By default all columns will use this comparator to perform sorting.
|
Constructor and Description |
---|
TableColumn()
Creates a default TableColumn with default cell factory, comparator, and
onEditCommit implementation.
|
TableColumn(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(EventType<E> eventType,
EventHandler<E> eventHandler)
Registers an event handler to this TableColumn.
|
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail)
Construct an event dispatch chain for this target.
|
ObjectProperty<Callback<TableColumn<S,T>,TableCell<S,T>>> |
cellFactoryProperty()
The cell factory for all cells in this column.
|
ObjectProperty<Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>>> |
cellValueFactoryProperty()
The cell value factory needs to be set to specify how to populate all
cells within a single TableColumn.
|
ObjectProperty<java.util.Comparator<T>> |
comparatorProperty()
Comparator function used when sorting this TableColumn.
|
ObjectProperty<ContextMenu> |
contextMenuProperty()
This menu will be shown whenever the user right clicks within the header
area of this TableColumn.
|
BooleanProperty |
editableProperty()
Specifies whether this TableColumn allows editing.
|
static <S,T> EventType<TableColumn.CellEditEvent<S,T>> |
editAnyEvent()
Parent event for any TableColumn edit event.
|
static <S,T> EventType<TableColumn.CellEditEvent<S,T>> |
editCancelEvent()
Indicates that the editing has been canceled, meaning that no change should
be made to the backing data source.
|
static <S,T> EventType<TableColumn.CellEditEvent<S,T>> |
editCommitEvent()
Indicates that the editing has been committed by the user, meaning that
a change should be made to the backing data source to reflect the new
data.
|
static <S,T> EventType<TableColumn.CellEditEvent<S,T>> |
editStartEvent()
Indicates that the user has performed some interaction to start an edit
event, or alternatively the
TableView.edit(int, javafx.scene.control.TableColumn)
method has been called. |
T |
getCellData(int index)
Returns the actual value for a cell at a given row index (and which
belongs to this TableColumn).
|
T |
getCellData(S item)
Returns the actual value for a cell from the given item.
|
Callback<TableColumn<S,T>,TableCell<S,T>> |
getCellFactory()
Gets the value of the property cellFactory.
|
ObservableValue<T> |
getCellObservableValue(int index)
Attempts to return an ObservableValue<T> for the item in the given
index (which is of type S).
|
ObservableValue<T> |
getCellObservableValue(S item)
Attempts to return an ObservableValue<T> for the given item (which
is of type S).
|
Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>> |
getCellValueFactory()
Gets the value of the property cellValueFactory.
|
ObservableList<TableColumn<S,?>> |
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()
The graphic shown in the TableColumn.
|
java.lang.String |
getId()
The id of this TableColumn.
|
double |
getMaxWidth()
Gets the value of the property maxWidth.
|
double |
getMinWidth()
Gets the value of the property minWidth.
|
EventHandler<TableColumn.CellEditEvent<S,T>> |
getOnEditCancel()
Gets the value of the property onEditCancel.
|
EventHandler<TableColumn.CellEditEvent<S,T>> |
getOnEditCommit()
Gets the value of the property onEditCommit.
|
EventHandler<TableColumn.CellEditEvent<S,T>> |
getOnEditStart()
Gets the value of the property onEditStart.
|
TableColumn<S,?> |
getParentColumn()
Gets the value of the property parentColumn.
|
double |
getPrefWidth()
Gets the value of the property prefWidth.
|
ObservableMap<java.lang.Object,java.lang.Object> |
getProperties()
Returns an observable map of properties on this TableColumn for use primarily
by application developers.
|
Node |
getSortNode()
Returns the current sort node set in this TableColumn.
|
TableColumn.SortType |
getSortType()
Gets the value of the property sortType.
|
java.lang.String |
getStyle()
The CSS style string associated to this TableColumn.
|
ObservableList<java.lang.String> |
getStyleClass()
A list of String identifiers which can be used to logically group
Nodes, specifically for an external style engine.
|
TableView<S> |
getTableView()
Gets the value of the property tableView.
|
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.
|
ObjectProperty<Node> |
graphicProperty()
The graphic in the TableColumn.
|
boolean |
hasProperties()
Tests if this TableColumn has properties.
|
StringProperty |
idProperty()
The id of this TableColumn.
|
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 TableColumn is permitted to be resized to.
|
DoubleProperty |
minWidthProperty()
The minimum width the TableColumn is permitted to be resized to.
|
ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> |
onEditCancelProperty()
This event handler will be fired when the user cancels editing a cell.
|
ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> |
onEditCommitProperty()
This event handler will be fired when the user successfully commits their
editing.
|
ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> |
onEditStartProperty()
This event handler will be fired when the user successfully initiates
editing.
|
ReadOnlyObjectProperty<TableColumn<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 TableColumn.
|
BooleanProperty |
resizableProperty()
Used to indicate whether the width of this column can change.
|
void |
setCellFactory(Callback<TableColumn<S,T>,TableCell<S,T>> value)
Sets the value of the property cellFactory.
|
void |
setCellValueFactory(Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>> value)
Sets the value of the property cellValueFactory.
|
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 graphic to show in the TableColumn to allow the user to
indicate graphically what is in the column.
|
void |
setId(java.lang.String value)
Sets the id of this TableColumn.
|
void |
setMaxWidth(double value)
Sets the value of the property maxWidth.
|
void |
setMinWidth(double value)
Sets the value of the property minWidth.
|
void |
setOnEditCancel(EventHandler<TableColumn.CellEditEvent<S,T>> value)
Sets the value of the property onEditCancel.
|
void |
setOnEditCommit(EventHandler<TableColumn.CellEditEvent<S,T>> value)
Sets the value of the property onEditCommit.
|
void |
setOnEditStart(EventHandler<TableColumn.CellEditEvent<S,T>> value)
Sets the value of the property onEditStart.
|
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)
The node to use as the "sort arrow", shown to the user in situations where
the TableColumn is part of the sort order.
|
void |
setSortType(TableColumn.SortType value)
Sets the value of the property sortType.
|
void |
setStyle(java.lang.String value)
A string representation of the CSS style associated with this
TableColumn.
|
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.
|
BooleanProperty |
sortableProperty()
A boolean property to toggle on and off the sortability of this column.
|
ObjectProperty<Node> |
sortNodeProperty()
The sort node is commonly seen represented as a triangle that rotates
on screen to indicate whether the TableColumn is part of the sort order,
and if so, what position in the sort order it is in.
|
ObjectProperty<TableColumn.SortType> |
sortTypeProperty()
Used to state whether this column, if it is part of the
TableView.sortOrder ObservableList, should be sorted in ascending
or descending order. |
StringProperty |
styleProperty()
The CSS style string associated to this TableColumn.
|
ReadOnlyObjectProperty<TableView<S>> |
tableViewProperty()
The TableView that this TableColumn belongs to.
|
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.
|
public final ReadOnlyObjectProperty<TableView<S>> tableViewProperty
getTableView()
public final StringProperty textProperty
getText()
,
setText(String)
public final BooleanProperty visibleProperty
isVisible()
,
setVisible(boolean)
public final ReadOnlyObjectProperty<TableColumn<S,?>> parentColumnProperty
columns
ObservableList of a TableColumn.getParentColumn()
public final ObjectProperty<ContextMenu> contextMenuProperty
getContextMenu()
,
setContextMenu(ContextMenu)
public final ObjectProperty<Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>>> cellValueFactoryProperty
Callback
that provides a TableColumn.CellDataFeatures
instance, and expects an
ObservableValue
to be returned. The returned ObservableValue instance
will be observed internally to allow for immediate updates to the value
to be reflected on screen.
An example of how to set a cell value factory is:
lastNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
// p.getValue() returns the Person instance for a particular TableView row
return p.getValue().lastNameProperty();
}
});
}
A common approach is to want to populate cells in a TableColumn using
a single value from a Java bean. To support this common scenario, there
is the PropertyValueFactory
class. Refer to this class for more
information on how to use it, but briefly here is how the above use case
could be simplified using the PropertyValueFactory class:
lastNameCol.setCellValueFactory(new PropertyValueFactory<Person,String>("lastName"));
public final ObjectProperty<Callback<TableColumn<S,T>,TableCell<S,T>>> cellFactoryProperty
default cell
factory
, but this can be replaced with a custom implementation, for
example to show data in a different way or to support editing.
There is a lot of documentation on creating custom cell factories
elsewhere (see Cell
and TableView
for example).
getCellFactory()
,
setCellFactory(Callback)
public final StringProperty idProperty
getId()
,
setId(String)
public final StringProperty styleProperty
getStyle()
,
setStyle(String)
public final ObjectProperty<Node> graphicProperty
getGraphic()
,
setGraphic(Node)
public final ObjectProperty<Node> sortNodeProperty
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 ObjectProperty<TableColumn.SortType> sortTypeProperty
TableView.sortOrder
ObservableList, should be sorted in ascending
or descending order. Simply toggling
this property will result in the sort order changing in the TableView,
assuming of course that this column is in the sortOrder ObservableList to
begin with.getSortType()
,
setSortType(SortType)
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 TableView.sortOrder
.
If 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<java.util.Comparator<T>> comparatorProperty
getComparator()
,
setComparator(Comparator)
public final BooleanProperty editableProperty
isEditable()
,
setEditable(boolean)
public final ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> onEditStartProperty
getOnEditStart()
,
setOnEditStart(EventHandler)
public final ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> onEditCommitProperty
public final ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> onEditCancelProperty
public static final Callback<TableColumn<?,?>,TableCell<?,?>> DEFAULT_CELL_FACTORY
graphic
property
if the item
is a Node, or it simply calls
toString()
if it is not null, setting the resulting string
inside the text
property.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)
.public TableColumn()
public TableColumn(java.lang.String text)
text
- The string to show when the TableColumn is placed within the TableView.public static <S,T> EventType<TableColumn.CellEditEvent<S,T>> editAnyEvent()
public static <S,T> EventType<TableColumn.CellEditEvent<S,T>> editStartEvent()
TableView.edit(int, javafx.scene.control.TableColumn)
method has been called.public static <S,T> EventType<TableColumn.CellEditEvent<S,T>> editCancelEvent()
public static <S,T> EventType<TableColumn.CellEditEvent<S,T>> editCommitEvent()
public final ReadOnlyObjectProperty<TableView<S>> tableViewProperty()
getTableView()
public final TableView<S> getTableView()
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)
public final TableColumn<S,?> getParentColumn()
columns
ObservableList of a TableColumn.public final ReadOnlyObjectProperty<TableColumn<S,?>> parentColumnProperty()
columns
ObservableList of a TableColumn.getParentColumn()
public final void setContextMenu(ContextMenu value)
public final ContextMenu getContextMenu()
public final ObjectProperty<ContextMenu> contextMenuProperty()
getContextMenu()
,
setContextMenu(ContextMenu)
public final void setCellValueFactory(Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>> value)
Callback
that provides a TableColumn.CellDataFeatures
instance, and expects an
ObservableValue
to be returned. The returned ObservableValue instance
will be observed internally to allow for immediate updates to the value
to be reflected on screen.
An example of how to set a cell value factory is:
lastNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
// p.getValue() returns the Person instance for a particular TableView row
return p.getValue().lastNameProperty();
}
});
}
A common approach is to want to populate cells in a TableColumn using
a single value from a Java bean. To support this common scenario, there
is the PropertyValueFactory
class. Refer to this class for more
information on how to use it, but briefly here is how the above use case
could be simplified using the PropertyValueFactory class:
lastNameCol.setCellValueFactory(new PropertyValueFactory<Person,String>("lastName"));
public final Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>> getCellValueFactory()
Callback
that provides a TableColumn.CellDataFeatures
instance, and expects an
ObservableValue
to be returned. The returned ObservableValue instance
will be observed internally to allow for immediate updates to the value
to be reflected on screen.
An example of how to set a cell value factory is:
lastNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
// p.getValue() returns the Person instance for a particular TableView row
return p.getValue().lastNameProperty();
}
});
}
A common approach is to want to populate cells in a TableColumn using
a single value from a Java bean. To support this common scenario, there
is the PropertyValueFactory
class. Refer to this class for more
information on how to use it, but briefly here is how the above use case
could be simplified using the PropertyValueFactory class:
lastNameCol.setCellValueFactory(new PropertyValueFactory<Person,String>("lastName"));
public final ObjectProperty<Callback<TableColumn.CellDataFeatures<S,T>,ObservableValue<T>>> cellValueFactoryProperty()
Callback
that provides a TableColumn.CellDataFeatures
instance, and expects an
ObservableValue
to be returned. The returned ObservableValue instance
will be observed internally to allow for immediate updates to the value
to be reflected on screen.
An example of how to set a cell value factory is:
lastNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
// p.getValue() returns the Person instance for a particular TableView row
return p.getValue().lastNameProperty();
}
});
}
A common approach is to want to populate cells in a TableColumn using
a single value from a Java bean. To support this common scenario, there
is the PropertyValueFactory
class. Refer to this class for more
information on how to use it, but briefly here is how the above use case
could be simplified using the PropertyValueFactory class:
lastNameCol.setCellValueFactory(new PropertyValueFactory<Person,String>("lastName"));
public final void setCellFactory(Callback<TableColumn<S,T>,TableCell<S,T>> value)
default cell
factory
, but this can be replaced with a custom implementation, for
example to show data in a different way or to support editing.
There is a lot of documentation on creating custom cell factories
elsewhere (see Cell
and TableView
for example).
public final Callback<TableColumn<S,T>,TableCell<S,T>> getCellFactory()
default cell
factory
, but this can be replaced with a custom implementation, for
example to show data in a different way or to support editing.
There is a lot of documentation on creating custom cell factories
elsewhere (see Cell
and TableView
for example).
public final ObjectProperty<Callback<TableColumn<S,T>,TableCell<S,T>>> cellFactoryProperty()
default cell
factory
, but this can be replaced with a custom implementation, for
example to show data in a different way or to support editing.
There is a lot of documentation on creating custom cell factories
elsewhere (see Cell
and TableView
for example).
getCellFactory()
,
setCellFactory(Callback)
public final void setId(java.lang.String value)
TableView
. The
default value is null
.public final java.lang.String getId()
public final StringProperty idProperty()
getId()
,
setId(String)
public final void setStyle(java.lang.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 java.lang.String getStyle()
public final StringProperty styleProperty()
getStyle()
,
setStyle(String)
public ObservableList<java.lang.String> getStyleClass()
public final void setGraphic(Node value)
Sets the graphic to show in the TableColumn to allow the user to indicate graphically what is in the column.
public final Node getGraphic()
public final ObjectProperty<Node> graphicProperty()
getGraphic()
,
setGraphic(Node)
public final void setSortNode(Node value)
public final Node getSortNode()
public final ObjectProperty<Node> sortNodeProperty()
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 ObjectProperty<TableColumn.SortType> sortTypeProperty()
TableView.sortOrder
ObservableList, should be sorted in ascending
or descending order. Simply toggling
this property will result in the sort order changing in the TableView,
assuming of course that this column is in the sortOrder ObservableList to
begin with.getSortType()
,
setSortType(SortType)
public final void setSortType(TableColumn.SortType value)
TableView.sortOrder
ObservableList, should be sorted in ascending
or descending order. Simply toggling
this property will result in the sort order changing in the TableView,
assuming of course that this column is in the sortOrder ObservableList to
begin with.public final TableColumn.SortType getSortType()
TableView.sortOrder
ObservableList, should be sorted in ascending
or descending order. Simply toggling
this property will result in the sort order changing in the TableView,
assuming of course that this column is in the sortOrder ObservableList to
begin with.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 TableView.sortOrder
.
If 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 TableView.sortOrder
.
If 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 TableView.sortOrder
.
If 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<java.util.Comparator<T>> 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()
isEditable()
,
setEditable(boolean)
public final void setOnEditStart(EventHandler<TableColumn.CellEditEvent<S,T>> value)
public final EventHandler<TableColumn.CellEditEvent<S,T>> getOnEditStart()
public final ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> onEditStartProperty()
getOnEditStart()
,
setOnEditStart(EventHandler)
public final void setOnEditCommit(EventHandler<TableColumn.CellEditEvent<S,T>> value)
public final EventHandler<TableColumn.CellEditEvent<S,T>> getOnEditCommit()
public final ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> onEditCommitProperty()
public final void setOnEditCancel(EventHandler<TableColumn.CellEditEvent<S,T>> value)
public final EventHandler<TableColumn.CellEditEvent<S,T>> getOnEditCancel()
public final ObjectProperty<EventHandler<TableColumn.CellEditEvent<S,T>>> onEditCancelProperty()
public final ObservableMap<java.lang.Object,java.lang.Object> 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 final ObservableList<TableColumn<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.
Modifying the order or contents of this ObservableList will result in the viewColumns ObservableList being reset to equal this ObservableList.
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 final ObservableValue<T> getCellObservableValue(int index)
items
list. If the index is
valid, this method will return an ObservableValue<T> for this
specific column.
This is achieved by calling the
cell value factory
, and returning whatever
it returns when passed a TableColumn.CellDataFeatures
containing the current
TableView
, as well as the TableColumn and item
provided to this method.
index
- The index of the item (of type S) for which an
ObservableValue<T> is sought.public final ObservableValue<T> getCellObservableValue(S item)
This is achieved by calling the
cell value factory
, and returning whatever
it returns when passed a TableColumn.CellDataFeatures
containing the current
TableView
, as well as the TableColumn and item
provided to this method.
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 registerjava.lang.NullPointerException
- 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 unregisterjava.lang.NullPointerException
- if the event type or handler is nullCopyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. Use is subject to