Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

After firing how can I leave tree expanded as is?

 
Brian Snyder2002
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After my TreeModel sends me a notice to update, I update my tree as follows:
[code]
private void newUser(int indexTo) {
Enumeration enum = getDescendantToggledPaths(this.getAnchorSelectionPath().getParentPath().getParentPath());
System.out.println("enum before = " + enum);
setModel(new DefaultTreeModel(root));
if(enum != null) {
System.out.println("enumAfter = " + enum);
while(enum.hasMoreElements()) {
TreePath path = (TreePath)enum.nextElement();
System.out.println("setting Path = " + path.toString());
//scrollPathToVisible(path);
expandPath(path);
}
}
}
[\code]
I want the tree to leave all of the previously expanded paths expanded. To do this, I record all the paths first by getting an enumeration, I then reset the view to include the new User, and then try to re=expand all the paths. The only path that remains expanded is the selected one.
How can I get all the previously expanded paths to remain open.
I read some of Manfred's postings, but his example opens ALL paths. I just want to open preexisiting ones.
Any ideas?
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your TreeModel told you to update, you probably
do not need to create a new TreeModel. If this is
related to your nonserializable User class from
another post, check the discussion of Tom Rodrigo's JTree question. After you fix the
serialization issue.
HTH,
Joe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic