aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTree ------odd thing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree ------odd thing" Watch "JTree ------odd thing" New topic
Author

JTree ------odd thing

mira yang
Ranch Hand

Joined: Nov 08, 2003
Posts: 33
hi everyone.
i have two frame ,one called 'firstFrame' and one called 'controlFrame'. they are both hold a Jtree. when you selected a leaf node in the controlFrame, it will invoke the method addNode(path,name) to add a new node in the firstFrame. But as you will see, it insert the node into the controlFrame.
first, excute CreateData to get the file 'tree.data'

// TreePanel is the class who holds and changes the tree


This class creates the two frame, 'firstFrame' and 'controlFrame'

And please note the output.
What's wrong?
mira yang
Ranch Hand

Joined: Nov 08, 2003
Posts: 33
is anyone else can answer my question?
maggie woo
Ranch Hand

Joined: Dec 18, 2003
Posts: 35
Your TreePanel's constructor adds itself as a TreeSelectionListener. That's why updates occur on the same tree.
You probably need to make the two TreePanels first in your TreeTest class, then add the appropriate TreePanel as a TreeSelectionListener to the other.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTree ------odd thing
 
Similar Threads
Subtree in JTree
JTree
showing a text file from a jtree selection path
Jtree adding nodes
JTree expand node and highlight