I have implemented the outline view in my application which consist of 200 node. How can I search a specific node and expand it ?
I have also looked breadthFirstEnumeration()
and depthFirstEnumeration()
method of DefaultMutableTreeNode
but could not find equivalent method in Outline.
The approach depends on the TreeModel
used to construct your OutlineModel
. In the FileTreeModel
cited, getRoot()
returns an arbitrary File
representing the root of a subtree in a hierarchical file system. This subtree can be searched recursively as shown here. Instead of printing the results, you would accumulate the File
instances representing the path into an array. That array would be used to construct a TreePath
. Given such a treePath
, you can reveal the corresponding node in a manner analogous to that shown here.
outline.expandPath(treePath);
outline.scrollRectToVisible(getPathBounds(treePath));