File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes After firing how can I leave tree expanded as is? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "After firing how can I leave tree expanded as is?" Watch "After firing how can I leave tree expanded as is?" New topic
Author

After firing how can I leave tree expanded as is?

Brian Snyder2002
Greenhorn

Joined: Jan 24, 2002
Posts: 11
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?


Java Developer<br />SCJ2P
Joe Gilvary
Ranch Hand

Joined: May 11, 2001
Posts: 152
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
 
 
subject: After firing how can I leave tree expanded as is?
 
Similar Threads
Tree and drawing within the same panel
JCheckBox in Jtree Problem
Searching a JTree
collapsing JTree
How to make the whole tree expanded?