This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JPopupMenu question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPopupMenu question" Watch "JPopupMenu question" New topic

JPopupMenu question

John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
Is there a way to get a JPopupMenu to expand its menus when clicking instead of when hovering the mouse over the menu?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10270

So you want to expand/collapse the submenus on mouse movements.
You can get the result by subclassing JMenu and adding a mouse listener to detect the mouse entered and mouse exited events. Check out JMenu#fireMenuXXX methods.

Warning:Take this with a grain of salt. I haven't tried it myself.
Also check out

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: JPopupMenu question