TreeCell implementation that draws a
TextField node inside the cell.
By default, the TextFieldTreeCell is rendered as a Label when not
being edited, and as a TextField when in editing mode. The TextField will, by
default, stretch to fill the entire tree cell.
| Modifier and Type | Field and Description |
|---|---|
| private ObjectProperty | |
| private HBox | |
| private TextField |
| Access | Constructor and Description |
|---|---|
| public | |
| public | TextFieldTreeCell(StringConverter<T>
A converter)converter that can convert
the given String (from what the user typed in) into an instance of
type T.Creates a TextFieldTreeCell that provides a |
| Modifier and Type | Method and Description |
|---|---|
| public void | cancelEdit()
Overrides javafx. Cancels an edit to the value of the cell. |
| public final ObjectProperty | |
| public static Callback | Returns: ACallback that can be inserted into the
cell factory property of a
TreeView, that enables textual editing of the content.Provides a |
| public static < The type of the elements contained within the TreeView T> Callback | Returns: ACallback that can be inserted into the
cell factory property of a
TreeView, that enables textual editing of the content.A converter)StringConverter that can convert the given String
(from what the user typed in) into an instance of type T.Provides a |
| public final StringConverter | Returns: theStringConverter used in this cellReturns the |
| private Node | |
| 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. |
| converter | back to summary |
|---|---|
| private ObjectProperty<StringConverter<T>> converter | |
| hbox | back to summary |
|---|---|
| private HBox hbox | |
| textField | back to summary |
|---|---|
| private TextField textField | |
| TextFieldTreeCell | back to summary |
|---|---|
| public TextFieldTreeCell() Creates a default TextFieldTreeCell with a null converter. Without a
| |
| TextFieldTreeCell | back to summary |
|---|---|
| public TextFieldTreeCell(StringConverter<T> converter) Creates a TextFieldTreeCell that provides 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.
| |
| converterProperty | back to summary |
|---|---|
| public final ObjectProperty The
| |
| forTreeView | back to summary |
|---|---|
| public static Callback Provides a | |
| forTreeView | back to summary |
|---|---|
| public static <T> Callback Provides a
| |
| getConverter | back to summary |
|---|---|
| public final StringConverter Returns the
| |
| getTreeItemGraphic | back to summary |
|---|---|
| private Node getTreeItemGraphic() | |
| 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:
| |