APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.control

public Class TreeTableColumn<S, T>

extends TableColumnBase<TreeItem<S>, T>
implements EventTarget
Class Inheritance
All Implemented Interfaces
javafx.event.EventTarget
Type Parameters
<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.
Imports
com.sun.javafx.scene.control.Properties, javafx.css.CssMetaData, .Styleable, java.util.Collections, .List, .Map, javafx.beans.property.ObjectProperty, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleObjectProperty, javafx.beans.value.ObservableValue, .WritableValue, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, .WeakListChangeListener, javafx.event.Event, .EventHandler, .EventTarget, .EventType, javafx.scene.Node, javafx.scene.control.skin.*, javafx.util.Callback

A TreeTableView is made up of a number of TreeTableColumn instances. Each TreeTableColumn in a TreeTableView 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 TreeTableColumn also contains the necessary properties to: When creating a TreeTableColumn instance, perhaps the two most important properties to set are the column 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:
firstNameCol.setCellValueFactory(new Callback<CellDataFeatures<Person, String>, ObservableValue<String>>() {
     public ObservableValue<String> call(CellDataFeatures<Person, String> p) {
         // p.getValue() returns the TreeItem<Person> instance for a particular TreeTableView row,
         // p.getValue().getValue() returns the Person instance inside the TreeItem<Person>
         return p.getValue().getValue().firstNameProperty();
     }
  });
 }
This approach assumes that the object returned from p.getValue().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) {
         // p.getValue() returns the TreeItem<Person> instance for a particular TreeTableView row,
         // p.getValue().getValue() returns the Person instance inside the TreeItem<Person>
         return new ReadOnlyObjectWrapper(p.getValue().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: javafx.scene.control.cell.TreeItemPropertyValueFactory. 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 TreeItemPropertyValueFactory 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.
Since
JavaFX 8.0
See Also
TableView, TableCell, TablePosition, javafx.scene.control.cell.TreeItemPropertyValueFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
TreeTableColumn.CellDataFeatures<
The TableView type
S
,
The TreeTableColumn type
T
>

A support class used in TreeTableColumn as a wrapper class to provide all necessary information for a particular Cell.

public static class
TreeTableColumn.CellEditEvent<
the type of the TreeItem instances contained within the TreeTableView
S
,
the type of the items contained within the TreeTableColumn
T
>

An event that is fired when a user performs an edit on a table cell.

public static enum
TreeTableColumn.SortType

Enumeration that specifies the type of sorting being applied to a specific column.

Field Summary

Modifier and TypeField and Description
private final ObjectProperty<Callback<TreeTableColumn<S, T>, TreeTableCell<S, T>>>
cellFactory

The cell factory for all cells in this column.

private ObjectProperty<Callback<TreeTableColumn.CellDataFeatures<S, T>, ObservableValue<T>>>
cellValueFactory

The cell value factory needs to be set to specify how to populate all cells within a single TreeTableColumn.

private final ObservableList<TreeTableColumn<S, ?>>
private ListChangeListener<TreeTableColumn<S, ?>>
public static final Callback<TreeTableColumn<?, ?>, TreeTableCell<?, ?>>
DEFAULT_CELL_FACTORY

If no cellFactory is specified on a TreeTableColumn instance, then this one will be used by default.

private EventHandler<TreeTableColumn.CellEditEvent<S, T>>
private static final String
private static final EventType<?>
private static final EventType<?>
private static final EventType<?>
private static final EventType<?>
private ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<S, T>>>
onEditCancel

This event handler will be fired when the user cancels editing a cell.

private ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<S, T>>>
onEditCommit

This event handler will be fired when the user successfully commits their editing.

private ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<S, T>>>
onEditStart

This event handler will be fired when the user successfully initiates editing.

private ObjectProperty<TreeTableColumn.SortType>
sortType

Used to state whether this column, if it is part of a sort order (see TreeTableView#getSortOrder() for more details), should be sorted in ascending or descending order.

private ReadOnlyObjectWrapper<TreeTableView<S>>
treeTableView

The TreeTableView that this TreeTableColumn belongs to.

private WeakListChangeListener<TreeTableColumn<S, ?>>
Inherited from javafx.scene.control.TableColumnBase:
DEFAULT_COMPARATORDEFAULT_MAX_WIDTHDEFAULT_MIN_WIDTHDEFAULT_WIDTHeventHandlerManager

Constructor Summary

AccessConstructor and Description
public
TreeTableColumn()

Creates a default TreeTableColumn with default cell factory, comparator, and onEditCommit implementation.

public
TreeTableColumn(String
The string to show when the TreeTableColumn is placed within the TreeTableView.
text
)

Creates a TreeTableColumn with the text set to the provided string, with default cell factory, comparator, and onEditCommit implementation.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<Callback<TreeTableColumn<S, T>, TreeTableCell<S, T>>>
public final ObjectProperty<Callback<TreeTableColumn.CellDataFeatures<S, T>, ObservableValue<T>>>
public static <
the type of the TreeTableView generic type
S
,
the type of the content in all cells in this TreeTableColumn
T
>
EventType<TreeTableColumn.CellEditEvent<S, T>>

Returns:

the edit event
editAnyEvent
()

Parent event for any TreeTableColumn edit event.

public static <
the type of the TreeTableView generic type
S
,
the type of the content in all cells in this TreeTableColumn
T
>
EventType<TreeTableColumn.CellEditEvent<S, T>>

Returns:

the edit cancel event
editCancelEvent
()

Indicates that the editing has been canceled, meaning that no change should be made to the backing data source.

public static <
the type of the TreeTableView generic type
S
,
the type of the content in all cells in this TreeTableColumn
T
>
EventType<TreeTableColumn.CellEditEvent<S, T>>

Returns:

the edit commit event
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.

public static <
the type of the TreeTableView generic type
S
,
the type of the content in all cells in this TreeTableColumn
T
>
EventType<TreeTableColumn.CellEditEvent<S, T>>

Returns:

the edit start event
editStartEvent
()

Indicates that the user has performed some interaction to start an edit event, or alternatively the TreeTableView#edit(int, javafx.scene.control.TreeTableColumn) method has been called.

public final Callback<TreeTableColumn<S, T>, TreeTableCell<S, T>>
public final ObservableValue<T>
getCellObservableValue(int index)

Implements abstract javafx.scene.control.TableColumnBase.getCellObservableValue.

Attempts to return an ObservableValue<T> for the item in the given index (which is of type S).

public final ObservableValue<T>
getCellObservableValue(TreeItem<S> item)

Implements abstract javafx.scene.control.TableColumnBase.getCellObservableValue.

Attempts to return an ObservableValue<T> for the given item (which is of type S).

public final Callback<TreeTableColumn.CellDataFeatures<S, T>, ObservableValue<T>>
public static List<CssMetaData<? extends Styleable, ?>>

Returns:

an empty list
getClassCssMetaData
()

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public final ObservableList<TreeTableColumn<S, ?>>
getColumns()

Implements abstract javafx.scene.control.TableColumnBase.getColumns.

This enables support for nested columns, which can be useful to group together related data.

public List<CssMetaData<? extends Styleable, ?>>
getCssMetaData()

Implements javafx.css.Styleable.getCssMetaData.

The CssMetaData of this Styleable.

public final EventHandler<TreeTableColumn.CellEditEvent<S, T>>
public final EventHandler<TreeTableColumn.CellEditEvent<S, T>>
public final EventHandler<TreeTableColumn.CellEditEvent<S, T>>
public final TreeTableColumn.SortType
public Node
getStyleableNode()

Overrides default javafx.css.Styleable.getStyleableNode.

Returns the Node that represents this Styleable object.

public Styleable

Returns:

getTreeTableView()
getStyleableParent
()

Implements javafx.css.Styleable.getStyleableParent.

Return the parent of this Styleable, or null if there is no parent.

public final TreeTableView<S>
public String

Returns:

"TreeTableColumn"
getTypeSelector
()

Implements javafx.css.Styleable.getTypeSelector.

The type of this Styleable that is to be used in selector matching.

public final ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<S, T>>>
public final ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<S, T>>>
public final ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<S, T>>>
private TableColumnHeader
public final void
public final void
public final void
public final void
public final void
public final void
pack-priv final void
public final ObjectProperty<TreeTableColumn.SortType>
public final ReadOnlyObjectProperty<TreeTableView<S>>
Inherited from javafx.scene.control.TableColumnBase:
addEventFilteraddEventHandlerbuildEventDispatchChaincomparatorPropertycontextMenuPropertydoSetWidtheditablePropertygetCellDatagetCellDatagetComparatorgetContextMenugetGraphicgetIdgetMaxWidthgetMinWidthgetParentColumngetPrefWidthgetPropertiesgetPseudoClassStatesgetSortNodegetStylegetStyleClassgetTextgetUserDatagetWidthgraphicPropertyhasPropertiesidPropertyisEditableisReorderableisResizableisSortableisVisiblemaxWidthPropertyminWidthPropertyparentColumnPropertyprefWidthPropertyremoveEventFilterremoveEventHandlerreorderablePropertyresizablePropertysetComparatorsetContextMenusetEditablesetGraphicsetIdsetMaxWidthsetMinWidthsetParentColumnsetPrefWidthsetReorderablesetResizablesetSortablesetSortNodesetStylesetTextsetUserDatasetVisiblesetWidthsortablePropertysortNodePropertystylePropertytextPropertyupdateColumnWidthsvisiblePropertywidthProperty