- java.lang.Object
- 
- javafx.scene.Node
- 
- javafx.scene.Parent
- 
- javafx.scene.layout.Region
- 
- javafx.scene.control.Control
- 
- javafx.scene.control.TreeView<T>
 
 
 
 
 
- 
- Type Parameters:
- T- The type of the item contained within the- TreeItemvalue property for all tree items in this TreeView.
 - All Implemented Interfaces:
- Styleable,- EventTarget,- Skinnable
 
 @DefaultProperty("root") public class TreeView<T> extends Control The TreeView control provides a view on to a tree root (of typeTreeItem). By using a TreeView, it is possible to drill down into the children of a TreeItem, recursively until a TreeItem has no children (that is, it is a leaf node in the tree). To facilitate this, unlike controls likeListView, in TreeView it is necessary to only specify therootnode.For more information on building up a tree using this approach, refer to the TreeItemclass documentation. Briefly however, to create a TreeView, you should do something along the lines of the following:TreeItem<String> root = new TreeItem<>("Root Node"); root.setExpanded(true); root.getChildren().addAll( new TreeItem<>("Item 1"), new TreeItem<>("Item 2"), new TreeItem<>("Item 3") ); TreeView<String> treeView = new TreeView<>(root);  A TreeView may be configured to optionally hide the root node by setting the showRootproperty tofalse. If the root node is hidden, there is one less level of indentation, and all children nodes of the root node are shown. By default, the root node is shown in the TreeView.TreeView Selection / Focus APIsTo track selection and focus, it is necessary to become familiar with the SelectionModelandFocusModelclasses. A TreeView has at most one instance of each of these classes, available fromselectionModelandfocusModelproperties respectively. Whilst it is possible to use this API to set a new selection model, in most circumstances this is not necessary - the default selection and focus models should work in most circumstances.The default SelectionModelused when instantiating a TreeView is an implementation of theMultipleSelectionModelabstract class. However, as noted in the API documentation for theselectionModeproperty, the default value isSelectionMode.SINGLE. To enable multiple selection in a default TreeView instance, it is therefore necessary to do the following:treeView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);Customizing TreeView VisualsThe visuals of the TreeView can be entirely customized by replacing the default cell factory. A cell factory is used to generateTreeCellinstances, which are used to represent an item in the TreeView. See theCellclass documentation for a more complete description of how to write custom Cells.EditingThis control supports inline editing of values, and this section attempts to give an overview of the available APIs and how you should use them. Firstly, cell editing most commonly requires a different user interface than when a cell is not being edited. This is the responsibility of the Cellimplementation being used. For TreeView, this is the responsibility of thecell factory. It is your choice whether the cell is permanently in an editing state (e.g. this is common forCheckBoxcells), or to switch to a different UI when editing begins (e.g. when a double-click is received on a cell).To know when editing has been requested on a cell, simply override the Cell.startEdit()method, and update the celltextandgraphicproperties as appropriate (e.g. set the text to null and set the graphic to be aTextField). Additionally, you should also overrideCell.cancelEdit()to reset the UI back to its original visual state when the editing concludes. In both cases it is important that you also ensure that you call the super method to have the cell perform all duties it must do to enter or exit its editing mode.Once your cell is in an editing state, the next thing you are most probably interested in is how to commit or cancel the editing that is taking place. This is your responsibility as the cell factory provider. Your cell implementation will know when the editing is over, based on the user input (e.g. when the user presses the Enter or ESC keys on their keyboard). When this happens, it is your responsibility to call Cell.commitEdit(Object)orCell.cancelEdit(), as appropriate.When you call Cell.commitEdit(Object)an event is fired to the TreeView, which you can observe by adding anEventHandlerviasetOnEditCommit(javafx.event.EventHandler). Similarly, you can also observe edit events foredit startandedit cancel.By default the TreeView edit commit handler is non-null, with a default handler that attempts to overwrite the property value for the item in the currently-being-edited row. It is able to do this as the Cell.commitEdit(Object)method is passed in the new value, and this is passed along to the edit commit handler via theTreeView.EditEventthat is fired. It is simply a matter of callingTreeView.EditEvent.getNewValue()to retrieve this value.It is very important to note that if you call setOnEditCommit(javafx.event.EventHandler)with your ownEventHandler, then you will be removing the default handler. Unless you then handle the writeback to the property (or the relevant data source), nothing will happen. You can work around this by using theNode.addEventHandler(javafx.event.EventType, javafx.event.EventHandler)method to add aeditCommitEvent()EventTypewith your desiredEventHandleras the second argument. Using this method, you will not replace the default implementation, but you will be notified when an edit commit has occurred.Hopefully this summary answers some of the commonly asked questions. Fortunately, JavaFX ships with a number of pre-built cell factories that handle all the editing requirements on your behalf. You can find these pre-built cell factories in the javafx.scene.control.cell package. 
- 
- 
Property SummaryProperties Type Property Description ObjectProperty<Callback<TreeView<T>,TreeCell<T>>>cellFactoryRepresents the cell factory that will be used for creating TreeCells, which are used to represent items in the TreeView.BooleanPropertyeditableSpecifies whether this TreeView is editable - only if the TreeView and the TreeCells within it are both editable will a TreeCell be able to go into their editing state.ReadOnlyObjectProperty<TreeItem<T>>editingItemA property used to represent the TreeItem currently being edited in the TreeView, if editing is taking place, or null if no item is being edited.ReadOnlyIntegerPropertyexpandedItemCountRepresents the number of tree nodes presently able to be visible in the TreeView.DoublePropertyfixedCellSizeSpecifies whether this control has cells that are a fixed height (of the specified value).ObjectProperty<FocusModel<TreeItem<T>>>focusModelThe FocusModel provides the API through which it is possible to control focus on zero or one rows of the TreeView.ObjectProperty<EventHandler<TreeView.EditEvent<T>>>onEditCancelThis event handler will be fired when the user cancels editing a cell.ObjectProperty<EventHandler<TreeView.EditEvent<T>>>onEditCommitThis property is used when the user performs an action that should result in their editing input being persisted.ObjectProperty<EventHandler<TreeView.EditEvent<T>>>onEditStartThis event handler will be fired when the user successfully initiates editing.ObjectProperty<EventHandler<ScrollToEvent<Integer>>>onScrollToCalled when there's a request to scroll an index into view usingscrollTo(int)ObjectProperty<TreeItem<T>>rootProperty representing the root node of the TreeView.ObjectProperty<MultipleSelectionModel<TreeItem<T>>>selectionModelThe SelectionModel provides the API through which it is possible to select single or multiple items within a TreeView, as well as inspect which rows have been selected by the user.BooleanPropertyshowRootProperty that represents whether or not the TreeView root node is visible.- 
Properties inherited from class javafx.scene.control.ControlcontextMenu, skin, tooltip
 - 
Properties inherited from class javafx.scene.layout.Regionbackground, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
 - 
Properties inherited from class javafx.scene.ParentneedsLayout
 - 
Properties inherited from class javafx.scene.NodeaccessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
 
- 
 - 
Nested Class SummaryNested Classes Modifier and Type Class Description static classTreeView.EditEvent<T>AnEventsubclass used specifically in TreeView for representing edit-related events.
 - 
Field Summary- 
Fields inherited from class javafx.scene.layout.RegionUSE_COMPUTED_SIZE, USE_PREF_SIZE
 - 
Fields inherited from class javafx.scene.NodeBASELINE_OFFSET_SAME_AS_HEIGHT
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ObjectProperty<Callback<TreeView<T>,TreeCell<T>>>cellFactoryProperty()Represents the cell factory that will be used for creating TreeCells, which are used to represent items in the TreeView.protected Skin<?>createDefaultSkin()Create a new instance of the default skin for this control.voidedit(TreeItem<T> item)Instructs the TreeView to begin editing the given TreeItem, if the TreeView iseditable.BooleanPropertyeditableProperty()Specifies whether this TreeView is editable - only if the TreeView and the TreeCells within it are both editable will a TreeCell be able to go into their editing state.static <T> EventType<TreeView.EditEvent<T>>editAnyEvent()An EventType that indicates some edit event has occurred.static <T> EventType<TreeView.EditEvent<T>>editCancelEvent()An EventType used to indicate that an edit event has just been canceled within the TreeView upon which the event was fired.static <T> EventType<TreeView.EditEvent<T>>editCommitEvent()An EventType that is used to indicate that an edit in a TreeView has been committed.ReadOnlyObjectProperty<TreeItem<T>>editingItemProperty()A property used to represent the TreeItem currently being edited in the TreeView, if editing is taking place, or null if no item is being edited.static <T> EventType<TreeView.EditEvent<T>>editStartEvent()An EventType used to indicate that an edit event has started within the TreeView upon which the event was fired.ReadOnlyIntegerPropertyexpandedItemCountProperty()Represents the number of tree nodes presently able to be visible in the TreeView.DoublePropertyfixedCellSizeProperty()Specifies whether this control has cells that are a fixed height (of the specified value).ObjectProperty<FocusModel<TreeItem<T>>>focusModelProperty()The FocusModel provides the API through which it is possible to control focus on zero or one rows of the TreeView.Callback<TreeView<T>,TreeCell<T>>getCellFactory()Returns the cell factory that will be used for creating TreeCells, which are used to represent items in the TreeView, or null if no custom cell factory has been set.static List<CssMetaData<? extends Styleable,?>>getClassCssMetaData()List<CssMetaData<? extends Styleable,?>>getControlCssMetaData()TreeItem<T>getEditingItem()Returns the TreeItem that is currently being edited in the TreeView, or null if no item is being edited.intgetExpandedItemCount()Gets the value of the property expandedItemCount.doublegetFixedCellSize()Returns the fixed cell size value.FocusModel<TreeItem<T>>getFocusModel()Returns the currently installedFocusModel.static intgetNodeLevel(TreeItem<?> node)Deprecated.This method does not correctly calculate the distance from the given TreeItem to the root of the TreeView.EventHandler<TreeView.EditEvent<T>>getOnEditCancel()Returns theEventHandlerthat will be called when the user cancels an edit.EventHandler<TreeView.EditEvent<T>>getOnEditCommit()Returns theEventHandlerthat will be called when the user commits an edit.EventHandler<TreeView.EditEvent<T>>getOnEditStart()Returns theEventHandlerthat will be called when the user begins an edit.EventHandler<ScrollToEvent<Integer>>getOnScrollTo()Gets the value of the property onScrollTo.TreeItem<T>getRoot()Returns the current root node of this TreeView, or null if no root node is specified.intgetRow(TreeItem<T> item)Returns the index position of the given TreeItem, assuming that it is currently accessible through the tree hierarchy (most notably, that all parent tree items are expanded).MultipleSelectionModel<TreeItem<T>>getSelectionModel()Returns the currently installed selection model.TreeItem<T>getTreeItem(int row)Returns the TreeItem in the given index, or null if it is out of bounds.intgetTreeItemLevel(TreeItem<?> node)Returns the number of levels of 'indentation' of the given TreeItem, based on how many times getParent() can be recursively called.booleanisEditable()Gets the value of the property editable.booleanisShowRoot()Returns true if the root of the TreeView should be shown, and false if it should not.protected voidlayoutChildren()Invoked during the layout pass to layout the children in thisParent.ObjectProperty<EventHandler<TreeView.EditEvent<T>>>onEditCancelProperty()This event handler will be fired when the user cancels editing a cell.ObjectProperty<EventHandler<TreeView.EditEvent<T>>>onEditCommitProperty()This property is used when the user performs an action that should result in their editing input being persisted.ObjectProperty<EventHandler<TreeView.EditEvent<T>>>onEditStartProperty()This event handler will be fired when the user successfully initiates editing.ObjectProperty<EventHandler<ScrollToEvent<Integer>>>onScrollToProperty()Called when there's a request to scroll an index into view usingscrollTo(int)ObjectqueryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)This method is called by the assistive technology to request the value for an attribute.voidrefresh()Callingrefresh()forces the TreeView control to recreate and repopulate the cells necessary to populate the visual bounds of the control.ObjectProperty<TreeItem<T>>rootProperty()Property representing the root node of the TreeView.voidscrollTo(int index)Scrolls the TreeView such that the item in the given index is visible to the end user.ObjectProperty<MultipleSelectionModel<TreeItem<T>>>selectionModelProperty()The SelectionModel provides the API through which it is possible to select single or multiple items within a TreeView, as well as inspect which rows have been selected by the user.voidsetCellFactory(Callback<TreeView<T>,TreeCell<T>> value)Sets the cell factory that will be used for creating TreeCells, which are used to represent items in the TreeView.voidsetEditable(boolean value)Sets the value of the property editable.voidsetFixedCellSize(double value)Sets the new fixed cell size for this control.voidsetFocusModel(FocusModel<TreeItem<T>> value)Sets theFocusModelto be used in the TreeView.voidsetOnEditCancel(EventHandler<TreeView.EditEvent<T>> value)Sets theEventHandlerthat will be called when the user cancels an edit.voidsetOnEditCommit(EventHandler<TreeView.EditEvent<T>> value)Sets theEventHandlerthat will be called when the user commits an edit.voidsetOnEditStart(EventHandler<TreeView.EditEvent<T>> value)Sets theEventHandlerthat will be called when the user begins an edit.voidsetOnScrollTo(EventHandler<ScrollToEvent<Integer>> value)Sets the value of the property onScrollTo.voidsetRoot(TreeItem<T> value)Sets the root node in this TreeView.voidsetSelectionModel(MultipleSelectionModel<TreeItem<T>> value)Sets theMultipleSelectionModelto be used in the TreeView.voidsetShowRoot(boolean value)Specifies whether the rootTreeItemshould be shown within this TreeView.BooleanPropertyshowRootProperty()Property that represents whether or not the TreeView root node is visible.- 
Methods inherited from class javafx.scene.control.ControlcomputeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, setContextMenu, setSkin, setTooltip, skinProperty, tooltipProperty
 - 
Methods inherited from class javafx.scene.layout.RegionbackgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
 - 
Methods inherited from class javafx.scene.ParentgetChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
 - 
Methods inherited from class javafx.scene.NodeaccessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface javafx.css.StyleablegetStyleableNode
 
- 
 
- 
- 
- 
Property Detail- 
cellFactorypublic final ObjectProperty<Callback<TreeView<T>,TreeCell<T>>> cellFactoryProperty Represents the cell factory that will be used for creating TreeCells, which are used to represent items in the TreeView.- Returns:
- the cell factory property
 
 - 
rootpublic final ObjectProperty<TreeItem<T>> rootProperty Property representing the root node of the TreeView.- See Also:
- getRoot(),- setRoot(TreeItem)
 
 - 
showRootpublic final BooleanProperty showRootProperty Property that represents whether or not the TreeView root node is visible.- See Also:
- isShowRoot(),- setShowRoot(boolean)
 
 - 
selectionModelpublic final ObjectProperty<MultipleSelectionModel<TreeItem<T>>> selectionModelProperty The SelectionModel provides the API through which it is possible to select single or multiple items within a TreeView, as well as inspect which rows have been selected by the user. Note that it has a generic type that must match the type of the TreeView itself.
 - 
focusModelpublic final ObjectProperty<FocusModel<TreeItem<T>>> focusModelProperty The FocusModel provides the API through which it is possible to control focus on zero or one rows of the TreeView. Generally the default implementation should be more than sufficient.- See Also:
- getFocusModel(),- setFocusModel(FocusModel)
 
 - 
expandedItemCountpublic final ReadOnlyIntegerProperty expandedItemCountProperty Represents the number of tree nodes presently able to be visible in the TreeView. This is essentially the count of all expanded tree items, and their children. For example, if just the root node is visible, the expandedItemCount will be one. If the root had three children and the root was expanded, the value will be four. - Since:
- JavaFX 8.0
- See Also:
- getExpandedItemCount()
 
 - 
fixedCellSizepublic final DoubleProperty fixedCellSizeProperty Specifies whether this control has cells that are a fixed height (of the specified value). If this value is less than or equal to zero, then all cells are individually sized and positioned. This is a slow operation. Therefore, when performance matters and developers are not dependent on variable cell sizes it is a good idea to set the fixed cell size value. Generally cells are around 24px, so setting a fixed cell size of 24 is likely to result in very little difference in visuals, but a improvement to performance.To set this property via CSS, use the -fx-fixed-cell-size property. This should not be confused with the -fx-cell-size property. The difference between these two CSS properties is that -fx-cell-size will size all cells to the specified size, but it will not enforce that this is the only size (thus allowing for variable cell sizes, and preventing the performance gains from being possible). Therefore, when performance matters use -fx-fixed-cell-size, instead of -fx-cell-size. If both properties are specified in CSS, -fx-fixed-cell-size takes precedence. - Since:
- JavaFX 8.0
- See Also:
- getFixedCellSize(),- setFixedCellSize(double)
 
 - 
editablepublic final BooleanProperty editableProperty Specifies whether this TreeView is editable - only if the TreeView and the TreeCells within it are both editable will a TreeCell be able to go into their editing state.- See Also:
- isEditable(),- setEditable(boolean)
 
 - 
editingItempublic final ReadOnlyObjectProperty<TreeItem<T>> editingItemProperty A property used to represent the TreeItem currently being edited in the TreeView, if editing is taking place, or null if no item is being edited. It is not possible to set the editing item, instead it is required that you call edit(javafx.scene.control.TreeItem).- See Also:
- getEditingItem()
 
 - 
onEditStartpublic final ObjectProperty<EventHandler<TreeView.EditEvent<T>>> onEditStartProperty This event handler will be fired when the user successfully initiates editing.- See Also:
- getOnEditStart(),- setOnEditStart(EventHandler)
 
 - 
onEditCommitpublic final ObjectProperty<EventHandler<TreeView.EditEvent<T>>> onEditCommitProperty This property is used when the user performs an action that should result in their editing input being persisted. The EventHandler in this property should not be called directly - instead call TreeCell.commitEdit(java.lang.Object)from within your custom TreeCell. This will handle firing this event, updating the view, and switching out of the editing state.- See Also:
- getOnEditCommit(),- setOnEditCommit(EventHandler)
 
 - 
onEditCancelpublic final ObjectProperty<EventHandler<TreeView.EditEvent<T>>> onEditCancelProperty This event handler will be fired when the user cancels editing a cell.- See Also:
- getOnEditCancel(),- setOnEditCancel(EventHandler)
 
 - 
onScrollTopublic ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty Called when there's a request to scroll an index into view usingscrollTo(int)- Since:
- JavaFX 8.0
- See Also:
- getOnScrollTo(),- setOnScrollTo(EventHandler)
 
 
- 
 - 
Constructor Detail- 
TreeViewpublic TreeView() Creates an empty TreeView.Refer to the TreeViewclass documentation for details on the default state of other properties.
 
- 
 - 
Method Detail- 
editAnyEventpublic static <T> EventType<TreeView.EditEvent<T>> editAnyEvent() An EventType that indicates some edit event has occurred. It is the parent type of all other edit events:editStartEvent(),editCommitEvent()andeditCancelEvent().- Type Parameters:
- T- the type of the TreeItem instances used in this TreeView
- Returns:
- An EventType that indicates some edit event has occurred.
 
 - 
editStartEventpublic static <T> EventType<TreeView.EditEvent<T>> editStartEvent() An EventType used to indicate that an edit event has started within the TreeView upon which the event was fired.- Type Parameters:
- T- the type of the TreeItem instances used in this TreeView
- Returns:
- An EventType used to indicate that an edit event has started.
 
 - 
editCancelEventpublic static <T> EventType<TreeView.EditEvent<T>> editCancelEvent() An EventType used to indicate that an edit event has just been canceled within the TreeView upon which the event was fired.- Type Parameters:
- T- the type of the TreeItem instances used in this TreeView
- Returns:
- An EventType used to indicate that an edit event has just been canceled.
 
 - 
editCommitEventpublic static <T> EventType<TreeView.EditEvent<T>> editCommitEvent() An EventType that is used to indicate that an edit in a TreeView has been committed. This means that user has made changes to the data of a TreeItem, and that the UI should be updated.- Type Parameters:
- T- the type of the TreeItem instances used in this TreeView
- Returns:
- An EventType that is used to indicate that an edit in a TreeView has been committed.
 
 - 
getNodeLevel@Deprecated(since="8u20") public static int getNodeLevel(TreeItem<?> node) Deprecated.This method does not correctly calculate the distance from the given TreeItem to the root of the TreeView. As of JavaFX 8.0_20, the proper way to do this is viagetTreeItemLevel(TreeItem)Returns the number of levels of 'indentation' of the given TreeItem, based on how many timesTreeItem.getParent()can be recursively called. If the TreeItem does not have any parent set, the returned value will be zero. For each time getParent() is recursively called, the returned value is incremented by one.Important note: This method is deprecated as it does not consider the root node. This means that this method will iterate past the root node of the TreeView control, if the root node has a parent. If this is important, call getTreeItemLevel(TreeItem)instead.- Parameters:
- node- The TreeItem for which the level is needed.
- Returns:
- An integer representing the number of parents above the given node, or -1 if the given TreeItem is null.
 
 - 
setCellFactorypublic final void setCellFactory(Callback<TreeView<T>,TreeCell<T>> value) Sets the cell factory that will be used for creating TreeCells, which are used to represent items in the TreeView. The factory works identically to the cellFactory in ListView and other complex composite controls. It is called to create a new TreeCell only when the system has determined that it doesn't have enough cells to represent the currently visible items. The TreeCell is reused by the system to represent different items in the tree when possible.Refer to the Cellclass documentation for more details.- Parameters:
- value- The- Callbackto use for generating TreeCell instances, or null if the default cell factory should be used.
 
 - 
getCellFactorypublic final Callback<TreeView<T>,TreeCell<T>> getCellFactory() Returns the cell factory that will be used for creating TreeCells, which are used to represent items in the TreeView, or null if no custom cell factory has been set. - Returns:
- the cell factory
 
 - 
cellFactoryPropertypublic final ObjectProperty<Callback<TreeView<T>,TreeCell<T>>> cellFactoryProperty() Represents the cell factory that will be used for creating TreeCells, which are used to represent items in the TreeView.- Returns:
- the cell factory property
 
 - 
setRootpublic final void setRoot(TreeItem<T> value) Sets the root node in this TreeView. See theTreeItemclass level documentation for more details.- Parameters:
- value- The- TreeItemthat will be placed at the root of the TreeView.
 
 - 
getRootpublic final TreeItem<T> getRoot() Returns the current root node of this TreeView, or null if no root node is specified.- Returns:
- The current root node, or null if no root node exists.
 
 - 
rootPropertypublic final ObjectProperty<TreeItem<T>> rootProperty() Property representing the root node of the TreeView.- See Also:
- getRoot(),- setRoot(TreeItem)
 
 - 
setShowRootpublic final void setShowRoot(boolean value) Specifies whether the rootTreeItemshould be shown within this TreeView.- Parameters:
- value- If true, the root TreeItem will be shown, and if false it will be hidden.
 
 - 
isShowRootpublic final boolean isShowRoot() Returns true if the root of the TreeView should be shown, and false if it should not. By default, the root TreeItem is visible in the TreeView.- Returns:
- true if the root of the TreeView should be shown
 
 - 
showRootPropertypublic final BooleanProperty showRootProperty() Property that represents whether or not the TreeView root node is visible.- See Also:
- isShowRoot(),- setShowRoot(boolean)
 
 - 
setSelectionModelpublic final void setSelectionModel(MultipleSelectionModel<TreeItem<T>> value) Sets theMultipleSelectionModelto be used in the TreeView. Despite a TreeView requiring aMultipleSelectionModel, it is possible to configure it to only allow single selection (seeMultipleSelectionModel.setSelectionMode(javafx.scene.control.SelectionMode)for more information).- Parameters:
- value- the- MultipleSelectionModelto be used
 
 - 
getSelectionModelpublic final MultipleSelectionModel<TreeItem<T>> getSelectionModel() Returns the currently installed selection model.- Returns:
- the currently installed selection model
 
 - 
selectionModelPropertypublic final ObjectProperty<MultipleSelectionModel<TreeItem<T>>> selectionModelProperty() The SelectionModel provides the API through which it is possible to select single or multiple items within a TreeView, as well as inspect which rows have been selected by the user. Note that it has a generic type that must match the type of the TreeView itself.
 - 
setFocusModelpublic final void setFocusModel(FocusModel<TreeItem<T>> value) Sets theFocusModelto be used in the TreeView.- Parameters:
- value- the- FocusModelto be used
 
 - 
getFocusModelpublic final FocusModel<TreeItem<T>> getFocusModel() Returns the currently installedFocusModel.- Returns:
- the currently installed FocusModel
 
 - 
focusModelPropertypublic final ObjectProperty<FocusModel<TreeItem<T>>> focusModelProperty() The FocusModel provides the API through which it is possible to control focus on zero or one rows of the TreeView. Generally the default implementation should be more than sufficient.- See Also:
- getFocusModel(),- setFocusModel(FocusModel)
 
 - 
expandedItemCountPropertypublic final ReadOnlyIntegerProperty expandedItemCountProperty() Represents the number of tree nodes presently able to be visible in the TreeView. This is essentially the count of all expanded tree items, and their children. For example, if just the root node is visible, the expandedItemCount will be one. If the root had three children and the root was expanded, the value will be four. - Since:
- JavaFX 8.0
- See Also:
- getExpandedItemCount()
 
 - 
getExpandedItemCountpublic final int getExpandedItemCount() Gets the value of the property expandedItemCount.- Property description:
- Represents the number of tree nodes presently able to be visible in the TreeView. This is essentially the count of all expanded tree items, and their children. - For example, if just the root node is visible, the expandedItemCount will be one. If the root had three children and the root was expanded, the value will be four. 
- Since:
- JavaFX 8.0
 
 - 
setFixedCellSizepublic final void setFixedCellSize(double value) Sets the new fixed cell size for this control. Any value greater than zero will enable fixed cell size mode, whereas a zero or negative value (or Region.USE_COMPUTED_SIZE) will be used to disabled fixed cell size mode.- Parameters:
- value- The new fixed cell size value, or a value less than or equal to zero (or Region.USE_COMPUTED_SIZE) to disable.
- Since:
- JavaFX 8.0
 
 - 
getFixedCellSizepublic final double getFixedCellSize() Returns the fixed cell size value. A value less than or equal to zero is used to represent that fixed cell size mode is disabled, and a value greater than zero represents the size of all cells in this control.- Returns:
- A double representing the fixed cell size of this control, or a value less than or equal to zero if fixed cell size mode is disabled.
- Since:
- JavaFX 8.0
 
 - 
fixedCellSizePropertypublic final DoubleProperty fixedCellSizeProperty() Specifies whether this control has cells that are a fixed height (of the specified value). If this value is less than or equal to zero, then all cells are individually sized and positioned. This is a slow operation. Therefore, when performance matters and developers are not dependent on variable cell sizes it is a good idea to set the fixed cell size value. Generally cells are around 24px, so setting a fixed cell size of 24 is likely to result in very little difference in visuals, but a improvement to performance.To set this property via CSS, use the -fx-fixed-cell-size property. This should not be confused with the -fx-cell-size property. The difference between these two CSS properties is that -fx-cell-size will size all cells to the specified size, but it will not enforce that this is the only size (thus allowing for variable cell sizes, and preventing the performance gains from being possible). Therefore, when performance matters use -fx-fixed-cell-size, instead of -fx-cell-size. If both properties are specified in CSS, -fx-fixed-cell-size takes precedence. - Since:
- JavaFX 8.0
- See Also:
- getFixedCellSize(),- setFixedCellSize(double)
 
 - 
setEditablepublic final void setEditable(boolean value) Sets the value of the property editable.- Property description:
- Specifies whether this TreeView is editable - only if the TreeView and the TreeCells within it are both editable will a TreeCell be able to go into their editing state.
 
 - 
isEditablepublic final boolean isEditable() Gets the value of the property editable.- Property description:
- Specifies whether this TreeView is editable - only if the TreeView and the TreeCells within it are both editable will a TreeCell be able to go into their editing state.
 
 - 
editablePropertypublic final BooleanProperty editableProperty() Specifies whether this TreeView is editable - only if the TreeView and the TreeCells within it are both editable will a TreeCell be able to go into their editing state.- See Also:
- isEditable(),- setEditable(boolean)
 
 - 
getEditingItempublic final TreeItem<T> getEditingItem() Returns the TreeItem that is currently being edited in the TreeView, or null if no item is being edited.- Returns:
- the TreeItem that is currently being edited in the TreeView
 
 - 
editingItemPropertypublic final ReadOnlyObjectProperty<TreeItem<T>> editingItemProperty() A property used to represent the TreeItem currently being edited in the TreeView, if editing is taking place, or null if no item is being edited. It is not possible to set the editing item, instead it is required that you call edit(javafx.scene.control.TreeItem).- See Also:
- getEditingItem()
 
 - 
setOnEditStartpublic final void setOnEditStart(EventHandler<TreeView.EditEvent<T>> value) Sets theEventHandlerthat will be called when the user begins an edit.- Parameters:
- value- the- EventHandlerthat will be called when the user begins an edit
 
 - 
getOnEditStartpublic final EventHandler<TreeView.EditEvent<T>> getOnEditStart() Returns theEventHandlerthat will be called when the user begins an edit.- Returns:
- the EventHandlerwhen the user begins an edit
 
 - 
onEditStartPropertypublic final ObjectProperty<EventHandler<TreeView.EditEvent<T>>> onEditStartProperty() This event handler will be fired when the user successfully initiates editing.- See Also:
- getOnEditStart(),- setOnEditStart(EventHandler)
 
 - 
setOnEditCommitpublic final void setOnEditCommit(EventHandler<TreeView.EditEvent<T>> value) Sets theEventHandlerthat will be called when the user commits an edit.- Parameters:
- value- the- EventHandlerthat will be called when the user commits an edit
 
 - 
getOnEditCommitpublic final EventHandler<TreeView.EditEvent<T>> getOnEditCommit() Returns theEventHandlerthat will be called when the user commits an edit.- Returns:
- the EventHandlerthat will be called when the user commits an edit
 
 - 
onEditCommitPropertypublic final ObjectProperty<EventHandler<TreeView.EditEvent<T>>> onEditCommitProperty() This property is used when the user performs an action that should result in their editing input being persisted. The EventHandler in this property should not be called directly - instead call TreeCell.commitEdit(java.lang.Object)from within your custom TreeCell. This will handle firing this event, updating the view, and switching out of the editing state.- See Also:
- getOnEditCommit(),- setOnEditCommit(EventHandler)
 
 - 
setOnEditCancelpublic final void setOnEditCancel(EventHandler<TreeView.EditEvent<T>> value) Sets theEventHandlerthat will be called when the user cancels an edit.- Parameters:
- value- the- EventHandlerthat will be called when the user cancels an edit
 
 - 
getOnEditCancelpublic final EventHandler<TreeView.EditEvent<T>> getOnEditCancel() Returns theEventHandlerthat will be called when the user cancels an edit.- Returns:
- the EventHandlerthat will be called when the user cancels an edit
 
 - 
onEditCancelPropertypublic final ObjectProperty<EventHandler<TreeView.EditEvent<T>>> onEditCancelProperty() This event handler will be fired when the user cancels editing a cell.- See Also:
- getOnEditCancel(),- setOnEditCancel(EventHandler)
 
 - 
layoutChildrenprotected void layoutChildren() Invoked during the layout pass to layout the children in thisParent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.Subclasses should override this function to layout content as needed. - Overrides:
- layoutChildrenin class- Control
 
 - 
editpublic void edit(TreeItem<T> item) Instructs the TreeView to begin editing the given TreeItem, if the TreeView iseditable. Once this method is called, if the currentcell factoryis set up to support editing, the Cell will switch its visual state to enable the user input to take place.- Parameters:
- item- The TreeItem in the TreeView that should be edited.
 
 - 
scrollTopublic void scrollTo(int index) Scrolls the TreeView such that the item in the given index is visible to the end user.- Parameters:
- index- The index that should be made visible to the user, assuming of course that it is greater than, or equal to 0, and less than the number of the visible items in the TreeView.
 
 - 
setOnScrollTopublic void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) Sets the value of the property onScrollTo.- Property description:
- Called when there's a request to scroll an index into view using scrollTo(int)
- Since:
- JavaFX 8.0
 
 - 
getOnScrollTopublic EventHandler<ScrollToEvent<Integer>> getOnScrollTo() Gets the value of the property onScrollTo.- Property description:
- Called when there's a request to scroll an index into view using scrollTo(int)
- Since:
- JavaFX 8.0
 
 - 
onScrollToPropertypublic ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() Called when there's a request to scroll an index into view usingscrollTo(int)- Since:
- JavaFX 8.0
- See Also:
- getOnScrollTo(),- setOnScrollTo(EventHandler)
 
 - 
getRowpublic int getRow(TreeItem<T> item) Returns the index position of the given TreeItem, assuming that it is currently accessible through the tree hierarchy (most notably, that all parent tree items are expanded). If a parent tree item is collapsed, the result is that this method will return -1 to indicate that the given tree item is not accessible in the tree.- Parameters:
- item- The TreeItem for which the index is sought.
- Returns:
- An integer representing the location in the current TreeView of the first instance of the given TreeItem, or -1 if it is null or can not be found (for example, if a parent (all the way up to the root) is collapsed).
 
 - 
getTreeItempublic TreeItem<T> getTreeItem(int row) Returns the TreeItem in the given index, or null if it is out of bounds.- Parameters:
- row- The index of the TreeItem being sought.
- Returns:
- The TreeItem in the given index, or null if it is out of bounds.
 
 - 
getTreeItemLevelpublic int getTreeItemLevel(TreeItem<?> node) Returns the number of levels of 'indentation' of the given TreeItem, based on how many times getParent() can be recursively called. If the given TreeItem is the root node of this TreeView, or if the TreeItem does not have any parent set, the returned value will be zero. For each time getParent() is recursively called, the returned value is incremented by one.- Parameters:
- node- The TreeItem for which the level is needed.
- Returns:
- An integer representing the number of parents above the given node, or -1 if the given TreeItem is null.
 
 - 
createDefaultSkinprotected Skin<?> 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-skinor set explicitly in a sub-class withsetSkin(...).- Overrides:
- createDefaultSkinin class- Control
- Returns:
- new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.
 
 - 
refreshpublic void refresh() Callingrefresh()forces the TreeView control to recreate and repopulate the cells necessary to populate the visual bounds of the control. In other words, this forces the TreeView to update what it is showing to the user. This is useful in cases where the underlying data source has changed in a way that is not observed by the TreeView itself.- Since:
- JavaFX 8u60
 
 - 
getClassCssMetaDatapublic static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData() - Returns:
- The CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
- Since:
- JavaFX 8.0
 
 - 
getControlCssMetaDatapublic List<CssMetaData<? extends Styleable,?>> getControlCssMetaData() - Overrides:
- getControlCssMetaDatain class- Control
- Returns:
- unmodifiable list of the controls css styleable properties
- Since:
- JavaFX 8.0
 
 - 
queryAccessibleAttributepublic Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) 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.- Overrides:
- queryAccessibleAttributein class- Control
- Parameters:
- attribute- the requested attribute
- parameters- optional list of parameters
- Returns:
- the value for the requested attribute
- See Also:
- AccessibleAttribute
 
 
- 
 
-