Forums Register Login

JPopUp

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
Ew. You guys are ugly with a capital UG. Here, maybe this tiny ad can help:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1774 times.
Similar Threads
Error when calling a constructor
How to create horizontal menus
Swing Menu item with no children?
JPopup That Looks Like ToolTip
incomplete menu shown
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:19:25.