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

public Class TreeCell<T>

extends IndexedCell<T>
Class Inheritance
Known Direct Subclasses
javafx.scene.control.cell.DefaultTreeCell
Type Parameters
<T>
The type of the value contained within the TreeItem property.
Imports
javafx.css.PseudoClass, javafx.beans.InvalidationListener, .Observable, .WeakInvalidationListener, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, .BooleanProperty, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, javafx.collections.ListChangeListener, .WeakListChangeListener, javafx.scene.AccessibleAction, .AccessibleAttribute, .AccessibleRole, .Node, javafx.scene.control.skin.TreeCellSkin, java.lang.ref.WeakReference, javafx.beans.value.ChangeListener, .ObservableValue, .WeakChangeListener

The Cell type used with the TreeView control. In addition to the API defined on IndexedCell, the TreeCell exposes additional states and pseudo classes for use by CSS.

A TreeCell watches the selection model of the TreeView for which it is associated, ensuring that it visually indicates to the user whether it is selected. When a TreeCell is selected, this is exposed both via the selected property, as well as via the 'selected' CSS pseudo class state.

Due to the fact that TreeCell extends from IndexedCell, each TreeCell also provides an index property. The index will be updated as cells are expanded and collapsed, and therefore should be considered a view index rather than a model index.

Finally, each TreeCell also has a reference back to the TreeView that it is being used with. Each TreeCell belongs to one and only one TreeView.

Since
JavaFX 2.0
See Also
TreeView, TreeItem

Field Summary

Modifier and TypeField and Description
private static final PseudoClass
private static final String
private ObjectProperty<Node>
private final InvalidationListener
private static final PseudoClass
private final InvalidationListener
private final ChangeListener<FocusModel<TreeItem<T>>>
focusModelPropertyListener

Listens to the focusModel property on the TreeView.

private boolean
private final InvalidationListener
private boolean
private final InvalidationListener
private final ListChangeListener<Integer>
private final ChangeListener<MultipleSelectionModel<TreeItem<T>>>
selectionModelPropertyListener

Listens to the selectionModel property on the TreeView.

private ReadOnlyObjectWrapper<TreeItem<T>>
private TreeItem<T>
private final InvalidationListener
private ReadOnlyObjectWrapper<TreeView<T>>
private boolean
private final WeakInvalidationListener
private final WeakInvalidationListener
private final WeakChangeListener<FocusModel<TreeItem<T>>>
private final WeakInvalidationListener
private final WeakInvalidationListener
private final WeakListChangeListener<Integer>
private final WeakChangeListener<MultipleSelectionModel<TreeItem<T>>>
private final WeakInvalidationListener

Constructor Summary

AccessConstructor and Description
public
TreeCell()

Creates a default TreeCell instance.

Method Summary

Modifier and TypeMethod and Description
public void
cancelEdit()

Overrides javafx.scene.control.Cell.cancelEdit.

Cancels an edit to the value of the cell.

public void
commitEdit(T newValue)

Overrides javafx.scene.control.Cell.commitEdit.

Commits an edit to the value of the cell.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final ObjectProperty<Node>

Returns:

the disclosure node
disclosureNodeProperty
()

The disclosure node is commonly seen represented as a triangle that rotates on screen to indicate whether or not the TreeItem that it is placed beside is expanded or collapsed.

private void
public void
executeAccessibleAction(AccessibleAction action, Object... parameters)

Overrides javafx.scene.control.Control.executeAccessibleAction.

This method is called by the assistive technology to request the action indicated by the argument should be executed.

public final Node

Returns:

the current disclosure node set in this TreeCell
getDisclosureNode
()

Returns the current disclosure node set in this TreeCell.

public final TreeItem<T>

Returns:

the TreeItem currently set in this TreeCell
getTreeItem
()

Returns the TreeItem currently set in this TreeCell.

public final TreeView<T>

Returns:

the TreeView associated with this TreeCell
getTreeView
()

Returns the TreeView associated with this TreeCell.

pack-priv void
indexChanged(int oldIndex, int newIndex)

Overrides javafx.scene.control.IndexedCell.indexChanged.

This method is called whenever the index is changed, regardless of whether the new index is the same as the old index.

public Object
queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

public final void
setDisclosureNode(Node
the disclosure node
value
)

The node to use as the "disclosure" triangle, or toggle, used for expanding and collapsing items.

private void
private void
public void
startEdit()

Overrides javafx.scene.control.Cell.startEdit.

Starts an edit to the value of the cell.

public final ReadOnlyObjectProperty<TreeItem<T>>

Returns:

the TreeItem property representing this TreeCell
treeItemProperty
()

Each TreeCell represents at most a single TreeItem, which is represented by this property.

public final ReadOnlyObjectProperty<TreeView<T>>

Returns:

the TreeView property of this TreeCell
treeViewProperty
()

A TreeCell is explicitly linked to a single TreeView instance, which is represented by this property.

private void
private void
private void
updateItem(int oldIndex)

private void
public final void
updateTreeItem(TreeItem<T>
The new TreeItem that should be associated with this TreeCell.

Note

This function is intended to be used by experts, primarily by those implementing new Skins. It is not common for developers or designers to access this function directly.

treeItem
)

Updates the TreeItem associated with this TreeCell.

public final void
updateTreeView(TreeView<T>
The new TreeView that should be associated with this TreeCell.

Note

This function is intended to be used by experts, primarily by those implementing new Skins. It is not common for developers or designers to access this function directly.

tree
)

Updates the TreeView associated with this TreeCell.

Inherited from javafx.scene.control.IndexedCell:
getIndexindexPropertyupdateIndex

Field Detail

COLLAPSED_PSEUDOCLASS_STATEback to summary
private static final PseudoClass COLLAPSED_PSEUDOCLASS_STATE
DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

Hides javafx.scene.control.IndexedCell.DEFAULT_STYLE_CLASS.

disclosureNodeback to summary
private ObjectProperty<Node> disclosureNode
editingListenerback to summary
private final InvalidationListener editingListener
EXPANDED_PSEUDOCLASS_STATEback to summary
private static final PseudoClass EXPANDED_PSEUDOCLASS_STATE
focusedListenerback to summary
private final InvalidationListener focusedListener
focusModelPropertyListenerback to summary
private final ChangeListener<FocusModel<TreeItem<T>>> focusModelPropertyListener

Listens to the focusModel property on the TreeView. Whenever the entire model is changed, we have to unhook the weakFocusedListener and update the focus.

isFirstRunback to summary
private boolean isFirstRun
leafListenerback to summary
private final InvalidationListener leafListener
oldIsExpandedback to summary
private boolean oldIsExpanded
rootPropertyListenerback to summary
private final InvalidationListener rootPropertyListener
selectedListenerback to summary
private final ListChangeListener<Integer> selectedListener
selectionModelPropertyListenerback to summary
private final ChangeListener<MultipleSelectionModel<TreeItem<T>>> selectionModelPropertyListener

Listens to the selectionModel property on the TreeView. Whenever the entire model is changed, we have to unhook the weakSelectedListener and update the selection.

treeItemback to summary
private ReadOnlyObjectWrapper<TreeItem<T>> treeItem
treeItemAtStartEditback to summary
private TreeItem<T> treeItemAtStartEdit
treeItemExpandedInvalidationListenerback to summary
private final InvalidationListener treeItemExpandedInvalidationListener
treeViewback to summary
private ReadOnlyObjectWrapper<TreeView<T>> treeView
updateEditingIndexback to summary
private boolean updateEditingIndex
weakEditingListenerback to summary
private final WeakInvalidationListener weakEditingListener
weakFocusedListenerback to summary
private final WeakInvalidationListener weakFocusedListener
weakFocusModelPropertyListenerback to summary
private final WeakChangeListener<FocusModel<TreeItem<T>>> weakFocusModelPropertyListener
weakLeafListenerback to summary
private final WeakInvalidationListener weakLeafListener
weakRootPropertyListenerback to summary
private final WeakInvalidationListener weakRootPropertyListener
weakSelectedListenerback to summary
private final WeakListChangeListener<Integer> weakSelectedListener
weakSelectionModelPropertyListenerback to summary
private final WeakChangeListener<MultipleSelectionModel<TreeItem<T>>> weakSelectionModelPropertyListener
weakTreeItemExpandedInvalidationListenerback to summary
private final WeakInvalidationListener weakTreeItemExpandedInvalidationListener

Constructor Detail

TreeCellback to summary
public TreeCell()

Creates a default TreeCell instance.

Method Detail

cancelEditback to summary
public void cancelEdit()

Overrides javafx.scene.control.Cell.cancelEdit.

Doc from javafx.scene.control.Cell.cancelEdit.

Cancels an edit to the value of the cell. Call this function to transition from an editing state into a non-editing state, without saving any user input.

Annotations
@Override
commitEditback to summary
public void commitEdit(T newValue)

Overrides javafx.scene.control.Cell.commitEdit.

Doc from javafx.scene.control.Cell.commitEdit.

Commits an edit to the value of the cell. Call this function when appropriate (based on the user interaction requirements of your cell editing user interface) to do two things:

  1. Fire the appropriate events back to the backing UI control (e.g., ListView). This will begin the process of pushing this edit back to the relevant data source / property (although it does not guarantee that this will be successful - that is dependent upon the specific edit commit handler being used). Refer to the UI control class javadoc for more detail.
  2. Begin the transition from an editing state into a non-editing state.

In general there is no need to override this method in custom cell implementations - it should be sufficient to simply call this method when appropriate (e.g., when the user pressed the Enter key, you may do something like cell.commitEdit(converter.fromString(textField.getText()));

Annotations
@Override
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
disclosureNodePropertyback to summary
public final ObjectProperty<Node> disclosureNodeProperty()

The disclosure node is commonly seen represented as a triangle that rotates on screen to indicate whether or not the TreeItem that it is placed beside is expanded or collapsed.

Returns:ObjectProperty<Node>

the disclosure node

doCancelEditingback to summary
private void doCancelEditing()
executeAccessibleActionback to summary
public void executeAccessibleAction(AccessibleAction action, Object... parameters)

Overrides javafx.scene.control.Control.executeAccessibleAction.

Doc from javafx.scene.control.Control.executeAccessibleAction.

This method is called by the assistive technology to request the action indicated by the argument should be executed.

This method is commonly overridden by subclasses to implement action that are required for a specific role.
If a particular action is not handled, the superclass implementation must be called.

Annotations
@Override
getDisclosureNodeback to summary
public final Node getDisclosureNode()

Returns the current disclosure node set in this TreeCell.

Returns:Node

the current disclosure node set in this TreeCell

getTreeItemback to summary
public final TreeItem<T> getTreeItem()

Returns the TreeItem currently set in this TreeCell.

Returns:TreeItem<T>

the TreeItem currently set in this TreeCell

getTreeViewback to summary
public final TreeView<T> getTreeView()

Returns the TreeView associated with this TreeCell.

Returns:TreeView<T>

the TreeView associated with this TreeCell

indexChangedback to summary
pack-priv void indexChanged(int oldIndex, int newIndex)

Overrides javafx.scene.control.IndexedCell.indexChanged.

Doc from javafx.scene.control.IndexedCell.indexChanged.

This method is called whenever the index is changed, regardless of whether the new index is the same as the old index.

Annotations
@Override
queryAccessibleAttributeback to summary
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

Doc from javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

This method is commonly overridden by subclasses to implement attributes that are required for a specific role.
If a particular attribute is not handled, the superclass implementation must be called.

Annotations
@Override
setDisclosureNodeback to summary
public final void setDisclosureNode(Node value)

The node to use as the "disclosure" triangle, or toggle, used for expanding and collapsing items. This is only used in the case of an item in the tree which contains child items. If not specified, the TreeCell's Skin implementation is responsible for providing a default disclosure node.

Parameters
value:Node

the disclosure node

setTreeItemback to summary
private void setTreeItem(TreeItem<T> value)
setTreeViewback to summary
private void setTreeView(TreeView<T> value)
startEditback to summary
public void startEdit()

Overrides javafx.scene.control.Cell.startEdit.

Doc from javafx.scene.control.Cell.startEdit.

Starts an edit to the value of the cell. Call this function to transition from a non-editing state into an editing state, if the cell is editable. If this cell is already in an editing state, it will stay in it.

Annotations
@Override
treeItemPropertyback to summary
public final ReadOnlyObjectProperty<TreeItem<T>> treeItemProperty()

Each TreeCell represents at most a single TreeItem, which is represented by this property.

Returns:ReadOnlyObjectProperty<TreeItem<T>>

the TreeItem property representing this TreeCell

treeViewPropertyback to summary
public final ReadOnlyObjectProperty<TreeView<T>> treeViewProperty()

A TreeCell is explicitly linked to a single TreeView instance, which is represented by this property.

Returns:ReadOnlyObjectProperty<TreeView<T>>

the TreeView property of this TreeCell

updateEditingback to summary
private void updateEditing()
updateFocusback to summary
private void updateFocus()
updateItemback to summary
private void updateItem(int oldIndex)
updateSelectionback to summary
private void updateSelection()
updateTreeItemback to summary
public final void updateTreeItem(TreeItem<T> treeItem)

Updates the TreeItem associated with this TreeCell.

Parameters
treeItem:TreeItem<T>

The new TreeItem that should be associated with this TreeCell.

Note

This function is intended to be used by experts, primarily by those implementing new Skins. It is not common for developers or designers to access this function directly.

updateTreeViewback to summary
public final void updateTreeView(TreeView<T> tree)

Updates the TreeView associated with this TreeCell.

Parameters
tree:TreeView<T>

The new TreeView that should be associated with this TreeCell.

Note

This function is intended to be used by experts, primarily by those implementing new Skins. It is not common for developers or designers to access this function directly.