• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to add diff popupmenu for diff level of Jtree

 
Titus Abraham
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello All,

if my Jtree has nodes like below

root
parent
child
child1
parent2

if i want dif menu associated with diff levels how do i do that ? any idea

best Regards,
Titus
 
Titus Abraham
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add to this.
i can try to do a solution like the one in the link below but i would like to avoid the multiple if else thereby the question
http://lists.xcf.berkeley.edu/lists/advanced-java/2000-July/030521.html

~titus
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you can do is subclass a DefaultMutableTreeNode and having a parameter in the constructor like this



that way, when you get the tree node that was clicked, you can then check which level this is in
 
Titus Abraham
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. but again i need to do a if else to check which level I am on right ?(i think there might not be any other way), just asking..
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes of course
 
Paul Clapham
Sheriff
Posts: 21872
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mark goking wrote:what you can do is subclass a DefaultMutableTreeNode and having a parameter in the constructor like this



that way, when you get the tree node that was clicked, you can then check which level this is in


That seems rather clumsy and error-prone compared to just calling its getLevel() method, which returns the desired information.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right. that would also work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!