Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPopUp

 
Drake Silver
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I'm wondering if someone can help me out with a Jpopup menu.
I've been reading, and it says that with every menu, a Jpopup is associated to it..
What?:confused"
I get from this that If I add a Jpopup, I can link the new popupmenu items to the Jmenu Items..
Did I Understand that correctly?
How would I join the popup's menu items to the Jmenu menu items?
thank you
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No... what that means is that the way that the Java API programmers have implemented the JMenu class is basically by making it a JButton that launches a JPopupMenu under it when the button is pressed. To make your own JPopupMenu, you would have to create it, and show it when appropriate actions were performed ( i.e. clicking a button, right clicking some area, etc. ). If you want to mirror menu items in your own JPopupMenu that are also inside menus in your JMenuBar I would suggest using Actions instead of JMenuItems. Use the AbstractAction class, in the constructor set up all the properties like the name, tooltip, icon, etc. and then write the actionPerformed() method to say what it does. This way you can add the Action to the JMenu, and later you can add the Action to the JPopupMenu, and have them behave the same.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic