TreeCell implementation that draws a
ComboBox node inside the cell.
By default, the ComboBoxTreeCell is rendered as a Label when not
being edited, and as a ComboBox when in editing mode. The ComboBox will, by
default, stretch to fill the entire tree cell.
To create a ComboBoxTreeCell, it is necessary to provide zero or more
items that will be shown to the user when the ComboBox menu is
showing. These items must be of the same type as the TreeView TreeItems, such
that upon selection, they replace the existing value in the
TreeItem#valueProperty().
| Modifier and Type | Field and Description |
|---|---|
| private ComboBox | |
| private BooleanProperty | |
| private ObjectProperty | |
| private HBox | |
| private final ObservableList |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ComboBoxTreeCell(T...
The items to show in the ComboBox popup menu when selected
by the user. items)Creates a default |
| public | ComboBoxTreeCell(StringConverter<T>
A converter, T... StringConverter that can convert an item of
type T into a user-readable string so that it may then be shown in
the ComboBox popup menu.The items to show in the ComboBox popup menu when selected
by the user. items)Creates a |
| public | ComboBoxTreeCell(ObservableList<T>
The items to show in the ComboBox popup menu when selected
by the user. items)Creates a default |
| public | ComboBoxTreeCell(StringConverter<T>
A converter, ObservableList<T> StringConverter that can convert an item of
type T into a user-readable string so that it may then be shown in
the ComboBox popup menu.The items to show in the ComboBox popup menu when selected
by the user. items)Creates a |
| Modifier and Type | Method and Description |
|---|---|
| public void | cancelEdit()
Overrides javafx. Cancels an edit to the value of the cell. |
| public final BooleanProperty | Returns: the property representing whether the ComboBox, when shown to the user, is editable or notA property representing whether the ComboBox, when shown to the user, is editable or not. |
| public final ObjectProperty | |
| public static < The type of the elements contained within the TreeView. T> Callback | Returns: ACallback that will return a TreeCell that is able to
work on the type of element contained within the TreeView.Creates a ComboBox cell factory for use in |
| public static < The type of the T> CallbackTreeItem elements contained within the
TreeView. | Returns: ACallback that will return a TreeCell that is able to
work on the type of element contained within the TreeView.An items)ObservableList containing zero or more items that
will be shown to the user when the ComboBox menu is showing.
These items must be of the same type as the TreeView generic type,
such that upon selection, they replace the existing value in the
TreeItem that is being edited (as noted in the
TreeView#editingItemProperty().Creates a ComboBox cell factory for use in |
| public static < The type of the elements contained within the TreeView. T> Callback | Returns: ACallback that will return a TreeCell that is able to
work on the type of element contained within the TreeView.A converter, final T... items)StringConverter to convert the given item (of
type T) to a String for displaying to the user.Creates a ComboBox cell factory for use in |
| public static < The type of the elements contained within the TreeView. T> Callback | Returns: ACallback that will return a TreeCell that is able to
work on the type of element contained within the TreeView.A converter, final ObservableList<T> StringConverter to convert the given item (of
type T) to a String for displaying to the user.An items)ObservableList containing zero or more items that
will be shown to the user when the ComboBox menu is showing.
These items must be of the same type as the TreeView generic type,
such that upon selection, they replace the existing value in the
TreeItem that is being edited (as noted in the
TreeView#editingItemProperty().Creates a ComboBox cell factory for use in |
| public final StringConverter | Returns: theStringConverter used in this cellReturns the |
| public ObservableList | Returns: the items to be displayed in this ComboBox when it is showingReturns the items to be displayed in the ComboBox when it is showing. |
| public final boolean | Returns: true if the ComboBox is editableReturns true if the ComboBox is editable. |
| public final void | setComboBoxEditable(boolean
the editable value to be set for this ComboBox value)Configures the ComboBox to be editable (to allow user input outside of the options provide in the dropdown list). |
| public final void | setConverter(StringConverter<T>
the value)StringConverter to be used in this cellSets the |
| public void | startEdit()
Overrides javafx. Starts an edit to the value of the cell. |
| public void | updateItem(T item, boolean empty)
Overrides javafx. The updateItem method should not be called by developers, but it is the best method for developers to override to allow for them to customise the visuals of the cell. |
| comboBox | back to summary |
|---|---|
| private ComboBox<T> comboBox | |
| comboBoxEditable | back to summary |
|---|---|
| private BooleanProperty comboBoxEditable | |
| converter | back to summary |
|---|---|
| private ObjectProperty<StringConverter<T>> converter | |
| hbox | back to summary |
|---|---|
| private HBox hbox | |
| items | back to summary |
|---|---|
| private final ObservableList<T> items | |
| ComboBoxTreeCell | back to summary |
|---|---|
| public ComboBoxTreeCell() Creates a default ComboBoxTreeCell with an empty items list. | |
| ComboBoxTreeCell | back to summary |
|---|---|
| public ComboBoxTreeCell(T... items) Creates a default
| |
| ComboBoxTreeCell | back to summary |
|---|---|
| public ComboBoxTreeCell(StringConverter<T> converter, T... items) Creates a
| |
| ComboBoxTreeCell | back to summary |
|---|---|
| public ComboBoxTreeCell(ObservableList<T> items) Creates a default
| |
| ComboBoxTreeCell | back to summary |
|---|---|
| public ComboBoxTreeCell(StringConverter<T> converter, ObservableList<T> items) Creates a
| |
| cancelEdit | back to summary |
|---|---|
| public void cancelEdit() Overrides javafx. Doc from javafx. 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.
| |
| comboBoxEditableProperty | back to summary |
|---|---|
| public final BooleanProperty comboBoxEditableProperty() A property representing whether the ComboBox, when shown to the user, is editable or not.
| |
| converterProperty | back to summary |
|---|---|
| public final ObjectProperty The
| |
| forTreeView | back to summary |
|---|---|
| public static <T> Callback Creates a ComboBox cell factory for use in | |
| forTreeView | back to summary |
|---|---|
| public static <T> Callback Creates a ComboBox cell factory for use in
| |
| forTreeView | back to summary |
|---|---|
| public static <T> Callback Creates a ComboBox cell factory for use in
| |
| forTreeView | back to summary |
|---|---|
| public static <T> Callback Creates a ComboBox cell factory for use in
| |
| getConverter | back to summary |
|---|---|
| public final StringConverter Returns the
| |
| getItems | back to summary |
|---|---|
| public ObservableList Returns the items to be displayed in the ComboBox when it is showing.
| |
| isComboBoxEditable | back to summary |
|---|---|
| public final boolean isComboBoxEditable() Returns true if the ComboBox is editable.
| |
| setComboBoxEditable | back to summary |
|---|---|
| public final void setComboBoxEditable(boolean value) Configures the ComboBox to be editable (to allow user input outside of the options provide in the dropdown list).
| |
| setConverter | back to summary |
|---|---|
| public final void setConverter(StringConverter<T> value) Sets the
| |
| startEdit | back to summary |
|---|---|
| public void startEdit() Overrides javafx. Doc from javafx. 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.
| |
| updateItem | back to summary |
|---|---|
| public void updateItem(T item, boolean empty) Overrides javafx. Doc from javafx. The updateItem method should not be called by developers, but it is the
best method for developers to override to allow for them to customise the
visuals of the cell. To clarify, developers should never call this method
in their code (they should leave it up to the UI control, such as the
It is very important that subclasses of Cell override the updateItem method properly, as failure to do so will lead to issues such as blank cells or cells with unexpected content appearing within them. Here is an example of how to properly override the updateItem method:
protected void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
} else {
setText(item.toString());
}
}
Note in this code sample two important points:
| |