• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree - Duplicate Node Name Problem  RSS feed

 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am encountering a peculiar problem; I have 2 nodes (DefaultMutableTreeNodes) with same name along 2 different Tree paths...

say:

path 1: root-> 11 -> 21 -> dir1

path 2: root-> dir1

The way user enters input is: root/11/21/dir1 or root/dir1

and appropriate treepath should be highlighted in JTree

I am using node.getPath() and hence the first path from the root is always being displayed... Is there a way I can get path1?

Has anybody solved similar problems...

Please advice

Thanks
R
 
Sainath Veepuri
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ravi,
I'am just trying to help you out. According to you..when the user enters a path of his choice, you have to higlight the same path in your tree.right?
If what I asked you is right, then you have to search for that node recursively instead of just using the getPath() method. Infact, life becomes much easier for me if you could post the code here.
- Sai
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!