1

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.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Ashish
  • 14,295
  • 21
  • 82
  • 127

1 Answers1

2

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));
Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thanks a lot for providing me the idea. Although I am not using FileTreeModel, I am using my own custom model and I will implement is in my way. Thanks again – Ashish May 13 '13 at 03:58