This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTree node  selection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree node  selection" Watch "JTree node  selection" New topic

JTree node selection

Vijay Krishna

Joined: Feb 10, 2005
Posts: 9

I hav two JTrees displayed side by side. These two trees have almost similar structure.My requirement is , when user selects a node from one tree, corresponding node in the second tree should be shown as selected automatically. Is there anyway?

Thanks in advance,
pankaj patil
Ranch Hand

Joined: Dec 19, 2004
Posts: 98
Can u give me the code how to generate tree

Pankaj Patil
Pat Hays
Ranch Hand

Joined: Aug 20, 2004
Posts: 138
Hello Super Dev

Here is the code.

Download Java GUI Builder, <a href="" target="_blank" rel="nofollow"></a>
Vijay Krishna

Joined: Feb 10, 2005
Posts: 9
Hi Pat Hays..

Thanks for ur replay..
My problem was how to find the corresponding node in the second tree.

DefaultMutableTreeNode correspondingNode = ???; // how to get this
matching node.

User can select any inner node , and I want to find that corresponding node in the second tree.
Vijay Krishna

Joined: Feb 10, 2005
Posts: 9

Finally I got a solution.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Super Dev,

We don't have too many rules around here but we do have a Naming Policy. Member names must appear to be a real name. Please adjust your display name accordingly. You can do so by clicking on the My Profile link towards the top of the page.

Thanks and welcome to Javaranch!

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: JTree node selection
It's not a secret anymore!