• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Adding different popupmenus to different jtree nodes

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to swing and I would like to add different popupmenus for different nodes of a tree. Can we do this using tree mouse listeners or tree model listeners ?

I've an application which constructs a jtree initially. Once the jtree is created, I am adding a custom mouse listener to jtree. In my custom mouse listener if the event is a popup trigger, I'm displaying a popup menu for the selected node. I've different action classes for each of the popup menu actions. In once of the action classes, a new node is inserted to the tree. After the node is added, I would like to display a different popup menu to the new node. As of now, I am still able to see the old popupmenu used for the tree initially. I think this can be done as this is a normal thing for anybody using jtrees.

I would really appreciate if anyone can guide me out or give some idea of doing this.

Thanks,
pashupathi
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You can do one thing add all menu items to popup menu. Before showing popup menu check which node is selected and accordingly control visibility of menu items.

Regards,
Anand
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic