I'm using this code to iterate all TreeView nodes.
for (TreeItem<DynamicTreeNodeModel> children1 : children)
{
ObservableList<TreeItem<DynamicTreeNodeModel>> children2 = children1.getChildren();
for (TreeItem<DynamicTreeNodeModel> children3 : children2)
{
ObservableList<TreeItem<DynamicTreeNodeModel>> children4 = children3.getChildren();
TreeItem<DynamicTreeNodeModel> tempValue = null;
for (TreeItem<DynamicTreeNodeModel> children5 : children4)
{
// some logic
}
}
}
Is there any better way to access low level nodes of the TreeView?
I made a utility class for traversing TreeTableView items depth-first. It supports streaming, visitor pattern and iterator pattern. It may be useful for someone.
You can just use a recursive method, which checks if the current node has children or not. If it has, it calls the same method again, else it prints the node.