File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JPopUp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPopUp" Watch "JPopUp" New topic


Drake Silver
Ranch Hand

Joined: Apr 21, 2002
Posts: 80
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..
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

"Shh, come one Now!"
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: JPopUp
It's not a secret anymore!