check model to request the current selection
state.
The following screenshot shows the CheckTreeView with some sample data:
To create the CheckTreeView shown in the screenshot, simply do the following:
// create the data to show in the CheckTreeView
CheckBoxTreeItem<String> root = new CheckBoxTreeItem<String>("Root");
root.setExpanded(true);
root.getChildren().addAll(
new CheckBoxTreeItem<String>("Jonathan"),
new CheckBoxTreeItem<String>("Eugene"),
new CheckBoxTreeItem<String>("Henri"),
new CheckBoxTreeItem<String>("Samir"));
// Create the CheckTreeView with the data
final CheckTreeView<String> checkTreeView = new CheckTreeView<>(root);
// and listen to the relevant events (e.g. when the checked items change).
checkTreeView.getCheckModel().getCheckedItems().addListener(new ListChangeListener<TreeItem<String>>() {
public void onChanged(ListChangeListener.Change<? extends TreeItem<String>> c) {
System.out.println(checkTreeView.getCheckModel().getCheckedItems());
}
});
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private ObjectProperty | checkModel
Properties |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CheckTreeView(final CheckBoxTreeItem<T>
The root tree item to display in the CheckTreeView. root)Creates a new CheckTreeView instance with the given CheckBoxTreeItem set as the tree root. |
| Modifier and Type | Method and Description |
|---|---|
| public final ObjectProperty | checkModelProperty()
The check model provides the API through which it is possible to check single or multiple items within a CheckTreeView, as well as inspect which items have been checked by the user. |
| public final CheckModel | |
| public BooleanProperty | getItemBooleanProperty(int index)
Returns the |
| public final void | setCheckModel(CheckModel<TreeItem<T>> value)
Sets the 'check model' to be used in the CheckTreeView - this is the
code that is responsible for representing the selected state of each
|
| protected void |
| checkModel | back to summary |
|---|---|
| private ObjectProperty<CheckModel<TreeItem<T>>> checkModel Properties | |
| CheckTreeView | back to summary |
|---|---|
| public CheckTreeView() Creates a new CheckTreeView instance with an empty tree of choices. | |
| CheckTreeView | back to summary |
|---|---|
| public CheckTreeView(final CheckBoxTreeItem<T> root) Creates a new CheckTreeView instance with the given CheckBoxTreeItem set as the tree root.
| |
| checkModelProperty | back to summary |
|---|---|
| public final ObjectProperty The check model provides the API through which it is possible to check single or multiple items within a CheckTreeView, as well as inspect which items have been checked by the user. Note that it has a generic type that must match the type of the CheckTreeView itself. | |
| getCheckModel | back to summary |
|---|---|
| public final CheckModel Returns the currently installed check model. | |
| getItemBooleanProperty | back to summary |
|---|---|
| public BooleanProperty getItemBooleanProperty(int index) Returns the | |
| setCheckModel | back to summary |
|---|---|
| public final void setCheckModel(CheckModel<TreeItem<T>> value) Sets the 'check model' to be used in the CheckTreeView - this is the
code that is responsible for representing the selected state of each
| |
| updateCheckModel | back to summary |
|---|---|
| protected void updateCheckModel() | |
| Modifier and Type | Field and Description |
|---|---|
| private ObservableList | |
| private final TreeItem | |
| private final CheckTreeView | treeView
* Internal properties * * |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | check(TreeItem<T> item)
Implements org. Checks the given item in the control. |
| public void | |
| public void | clearCheck(TreeItem<T> item)
Implements org. Unchecks the given item in the control |
| public void | clearChecks()
Implements org. Unchecks all items in the control |
| public ObservableList | getCheckedItems()
Implements org. Returns a read-only list of the currently checked items in the control. |
| public int | getItemCount()
Implements org. * Implementing abstract API * * |
| public boolean | isChecked(TreeItem<T> item)
Implements org. Returns true if the given item is checked in the control. |
| public boolean | isEmpty()
Implements org. Returns true if there are no checked items in the control. |
| private void | |
| private void | |
| private void | |
| public void | toggleCheckState(TreeItem<T> item)
Implements org. Toggles the check state for the given item in the control. |
| checkedItems | back to summary |
|---|---|
| private ObservableList<TreeItem<T>> checkedItems | |
| root | back to summary |
|---|---|
| private final TreeItem<T> root | |
| treeView | back to summary |
|---|---|
| private final CheckTreeView<T> treeView * Internal properties * * | |
| CheckTreeViewCheckModel | back to summary |
|---|---|
| pack-priv CheckTreeViewCheckModel(final CheckTreeView<T> treeView) * Constructors * * | |
| check | back to summary |
|---|---|
| public void check(TreeItem<T> item) Implements org. Doc from org. Checks the given item in the control.
| |
| checkAll | back to summary |
|---|---|
| public void checkAll() Implements org. Doc from org. Checks all items in the control
| |
| clearCheck | back to summary |
|---|---|
| public void clearCheck(TreeItem<T> item) Implements org. Doc from org. Unchecks the given item in the control
| |
| clearChecks | back to summary |
|---|---|
| public void clearChecks() Implements org. Doc from org. Unchecks all items in the control
| |
| getCheckedItems | back to summary |
|---|---|
| public ObservableList Implements org. Doc from org. Returns a read-only list of the currently checked items in the control.
| |
| getItemCount | back to summary |
|---|---|
| public int getItemCount() Implements org. * Implementing abstract API * *
| |
| isChecked | back to summary |
|---|---|
| public boolean isChecked(TreeItem<T> item) Implements org. Doc from org. Returns true if the given item is checked in the control.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements org. Doc from org. Returns true if there are no checked items in the control.
| |
| iterateOverTree | back to summary |
|---|---|
| private void iterateOverTree(Consumer<TreeItem<T>> consumer) * Private Implementation * * | |
| processChildren | back to summary |
|---|---|
| private void processChildren(Consumer<TreeItem<T>> consumer, List<TreeItem<T>> children) | |
| processNode | back to summary |
|---|---|
| private void processNode(Consumer<TreeItem<T>> consumer, TreeItem<T> node) | |
| toggleCheckState | back to summary |
|---|---|
| public void toggleCheckState(TreeItem<T> item) Implements org. Doc from org. Toggles the check state for the given item in the control.
| |