Spec-Zone .ru
спецификации, руководства, описания, API
|
T
- The type of the item contained within the TreeItem
value
property for all tree items in this TreeView.public class TreeView<T> extends Control
TreeItem
). 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
like ListView
, in TreeView it is necessary to only
specify the root
node.
For more information on building up a tree using this approach, refer to the
TreeItem
class documentation. Briefly however, to create a TreeView,
you should do something along the lines of the following:
TreeItem<String> root = new TreeItem<String>("Root Node");
root.setExpanded(true);
root.getChildren().addAll(
new TreeItem<String>("Item 1"),
new TreeItem<String>("Item 2"),
new TreeItem<String>("Item 3")
);
TreeView<String> treeView = new TreeView<String>(root);
A TreeView may be configured to optionally hide the root node by setting the
showRoot
property to false
. 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.
The visuals of a TreeView can be entirely customized by creating a
cellFactory
for the TreeView. The cell
factory is used for generating TreeCell
instances which will be used
to represent a single TreeItem in the TreeView. See the Cell
class
documentation for a more complete description of how to write custom cells.
Type | Property and Description |
---|---|
ObjectProperty<Callback<TreeView<T>,TreeCell<T>>> |
cellFactory
Represents the cell factory that will be used for creating TreeCells,
which are used to represent items in the TreeView.
|
BooleanProperty |
editable
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.
|
ReadOnlyObjectProperty<TreeItem<T>> |
editingItem
A property used to represent the TreeItem currently being edited
in the TreeView, if editing is taking place, or -1 if no item is being edited.
|
ObjectProperty<FocusModel<TreeItem<T>>> |
focusModel
The 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>>> |
onEditCancel
This event handler will be fired when the user cancels editing a cell.
|
ObjectProperty<EventHandler<TreeView.EditEvent<T>>> |
onEditCommit
This property is used when the user performs an action that should
result in their editing input being persisted.
|
ObjectProperty<EventHandler<TreeView.EditEvent<T>>> |
onEditStart
This event handler will be fired when the user successfully initiates
editing.
|
ObjectProperty<TreeItem<T>> |
root
Property representing the root node of the TreeView.
|
ObjectProperty<MultipleSelectionModel<TreeItem<T>>> |
selectionModel
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.
|
BooleanProperty |
showRoot
Property that represents whether or not the TreeView root node is visible.
|
contextMenuProperty, heightProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, prefHeightProperty, prefWidthProperty, skinProperty, tooltipProperty, widthProperty
needsLayoutProperty
blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, managedProperty, mouseTransparentProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDraggedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onScrollProperty, opacityProperty, parentProperty, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty
Modifier and Type | Class and Description |
---|---|
static class |
TreeView.EditEvent<T>
An
Event subclass used specifically in TreeView for representing
edit-related events. |
USE_COMPUTED_SIZE, USE_PREF_SIZE
Constructor and Description |
---|
TreeView()
Creates an empty TreeView.
|
TreeView(TreeItem<T> root)
Creates a TreeView with the provided root node.
|
Modifier and Type | Method and 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.
|
void |
edit(TreeItem<T> item)
Instructs the TreeView to begin editing the given TreeItem.
|
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.
|
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 -1 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.
|
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.
|
TreeItem<T> |
getEditingItem()
Returns the TreeItem that is currently being edited in the TreeView,
or null if no item is being edited.
|
FocusModel<TreeItem<T>> |
getFocusModel()
Returns the currently installed
FocusModel . |
static int |
getNodeLevel(TreeItem<?> node)
Returns the number of levels of 'indentation' of the given TreeItem,
based on how many times getParent() can be recursively called.
|
EventHandler<TreeView.EditEvent<T>> |
getOnEditCancel()
Returns the
EventHandler that will be called when the user cancels
an edit. |
EventHandler<TreeView.EditEvent<T>> |
getOnEditCommit()
Returns the
EventHandler that will be called when the user commits
an edit. |
EventHandler<TreeView.EditEvent<T>> |
getOnEditStart()
Returns the
EventHandler that will be called when the user begins
an edit. |
TreeItem<T> |
getRoot()
Returns the current root node of this TreeView, or null if no root node
is specified.
|
int |
getRow(TreeItem<T> item)
Returns the index position of the given TreeItem, taking into account the
current state of each TreeItem (i.e.
|
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.
|
boolean |
isEditable()
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.
|
boolean |
isShowRoot()
Returns true if the root of the TreeView should be shown, and false if
it should not.
|
protected void |
layoutChildren()
Invoked during the layout pass to layout the children in this
Parent . |
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<TreeItem<T>> |
rootProperty()
Property representing the root node of the TreeView.
|
void |
scrollTo(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.
|
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.
|
void |
setEditable(boolean value)
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.
|
void |
setFocusModel(FocusModel<TreeItem<T>> value)
Sets the
FocusModel to be used in the TreeView. |
void |
setOnEditCancel(EventHandler<TreeView.EditEvent<T>> value)
Sets the
EventHandler that will be called when the user cancels
an edit. |
void |
setOnEditCommit(EventHandler<TreeView.EditEvent<T>> value)
Sets the
EventHandler that will be called when the user commits
an edit. |
void |
setOnEditStart(EventHandler<TreeView.EditEvent<T>> value)
Sets the
EventHandler that will be called when the user begins
an edit. |
void |
setRoot(TreeItem<T> value)
Sets the root node in this TreeView.
|
void |
setSelectionModel(MultipleSelectionModel<TreeItem<T>> value)
Sets the
MultipleSelectionModel to be used in the TreeView. |
void |
setShowRoot(boolean value)
Specifies whether the root
TreeItem should be shown within this
TreeView. |
BooleanProperty |
showRootProperty()
Property that represents whether or not the TreeView root node is visible.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, getBaselineOffset, getContextMenu, getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, getSkin, getTooltip, getUserAgentStylesheet, getWidth, heightProperty, intersects, isResizable, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, setContextMenu, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setPrefHeight, setPrefSize, setPrefWidth, setSkin, setTooltip, setWidth, skinProperty, tooltipProperty, widthProperty
getChildren, getChildrenUnmodifiable, getManagedChildren, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, setNeedsLayout
addEventFilter, addEventHandler, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragged, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnScroll, getOpacity, getParent, getProperties, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getUserData, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToScene, localToScene, localToScene, lookupAll, managedProperty, mouseTransparentProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDraggedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onScrollProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragged, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnScroll, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, startDragAndDrop, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, visibleProperty
getCellFactory()
,
setCellFactory(Callback)
getRoot()
,
setRoot(TreeItem)
isShowRoot()
,
setShowRoot(boolean)
getFocusModel()
,
setFocusModel(FocusModel)
isEditable()
,
setEditable(boolean)
A property used to represent the TreeItem currently being edited in the TreeView, if editing is taking place, or -1 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)
.
getEditingItem()
getOnEditStart()
,
setOnEditStart(EventHandler)
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.
public static <T> EventType<TreeView.EditEvent<T>> editAnyEvent()
editStartEvent()
,
editCommitEvent()
and editCancelEvent()
.public static <T> EventType<TreeView.EditEvent<T>> editStartEvent()
public static <T> EventType<TreeView.EditEvent<T>> editCancelEvent()
public static <T> EventType<TreeView.EditEvent<T>> editCommitEvent()
public static int getNodeLevel(TreeItem<?> node)
node
- The TreeItem for which the level is needed.public final void setCellFactory(Callback<TreeView<T>,TreeCell<T>> value)
Refer to the Cell
class documentation for more details.
value
- The Callback
to use for generating TreeCell instances,
or null if the default cell factory should be used.public 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.
public final ObjectProperty<Callback<TreeView<T>,TreeCell<T>>> cellFactoryProperty()
getCellFactory()
,
setCellFactory(Callback)
public final void setRoot(TreeItem<T> value)
TreeItem
class level
documentation for more details.value
- The TreeItem
that will be placed at the root of the
TreeView.public final TreeItem<T> getRoot()
public final ObjectProperty<TreeItem<T>> rootProperty()
getRoot()
,
setRoot(TreeItem)
public final void setShowRoot(boolean value)
TreeItem
should be shown within this
TreeView.value
- If true, the root TreeItem will be shown, and if false it
will be hidden.public final boolean isShowRoot()
public final BooleanProperty showRootProperty()
isShowRoot()
,
setShowRoot(boolean)
public final void setSelectionModel(MultipleSelectionModel<TreeItem<T>> value)
MultipleSelectionModel
to be used in the TreeView.
Despite a TreeView requiring a MultipleSelectionModel
,
it is possible to configure it to only allow single selection (see
MultipleSelectionModel.setSelectionMode(javafx.scene.control.SelectionMode)
for more information).public final MultipleSelectionModel<TreeItem<T>> getSelectionModel()
public final ObjectProperty<MultipleSelectionModel<TreeItem<T>>> selectionModelProperty()
public final void setFocusModel(FocusModel<TreeItem<T>> value)
FocusModel
to be used in the TreeView.public final FocusModel<TreeItem<T>> getFocusModel()
FocusModel
.public final ObjectProperty<FocusModel<TreeItem<T>>> focusModelProperty()
getFocusModel()
,
setFocusModel(FocusModel)
public final void setEditable(boolean value)
public final boolean isEditable()
public final BooleanProperty editableProperty()
isEditable()
,
setEditable(boolean)
public final TreeItem<T> getEditingItem()
public final ReadOnlyObjectProperty<TreeItem<T>> editingItemProperty()
A property used to represent the TreeItem currently being edited in the TreeView, if editing is taking place, or -1 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)
.
getEditingItem()
public final void setOnEditStart(EventHandler<TreeView.EditEvent<T>> value)
EventHandler
that will be called when the user begins
an edit.public final EventHandler<TreeView.EditEvent<T>> getOnEditStart()
EventHandler
that will be called when the user begins
an edit.public final ObjectProperty<EventHandler<TreeView.EditEvent<T>>> onEditStartProperty()
getOnEditStart()
,
setOnEditStart(EventHandler)
public final void setOnEditCommit(EventHandler<TreeView.EditEvent<T>> value)
EventHandler
that will be called when the user commits
an edit.public final EventHandler<TreeView.EditEvent<T>> getOnEditCommit()
EventHandler
that will be called when the user commits
an edit.public 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.
public final void setOnEditCancel(EventHandler<TreeView.EditEvent<T>> value)
EventHandler
that will be called when the user cancels
an edit.public final EventHandler<TreeView.EditEvent<T>> getOnEditCancel()
EventHandler
that will be called when the user cancels
an edit.public final ObjectProperty<EventHandler<TreeView.EditEvent<T>>> onEditCancelProperty()
protected void layoutChildren()
Parent
. 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.
layoutChildren
in class Control
public void edit(TreeItem<T> item)
cell factory
is set up to support editing,
the Cell will switch its visual state to enable the user input to take place.item
- The TreeItem in the TreeView that should be edited.public void scrollTo(int index)
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.public int getRow(TreeItem<T> item)
item
- The TreeItem for which the index is sought.Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to