Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jtree and Popup Menu  RSS feed

 
Reeti Saha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTree, and want when user right-clicks on tree items, it will show a popup menu. But the items on the popup menu depend upon which tree item was right-clicked.
Can anyone pls. give me some sample code?
Regards
Reeti
 
Martin Schneider
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your node object should have some kind of id so you can tell the difference between nodes. When popping up menu you should do something like this:
 
Reeti Saha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
I'm not very comfotable with JTree..
It would be of much help, if you can give me a sample code example containing the JTree and JPopupMenu, so that I can utilise that.
Regards
Reeti
 
Martin Schneider
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I didn't tested this code
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!