This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Accelerator keys for Pop Up menu-items Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Accelerator keys for Pop Up menu-items " Watch "Accelerator keys for Pop Up menu-items " New topic
Author

Accelerator keys for Pop Up menu-items

Mohit J Kumar
Greenhorn

Joined: Apr 08, 2010
Posts: 28

Is there any way to set accelerator keys to pop up menu items.
I have a pop up menu on JTable and I want to set accelerator keys to its menu items. I also want to display the accelerator keys on the menu item's label, exactly the same way as they are displayed in case of menu-bar.
(see the File menu(items) above on your browser).


"It's good to B in touch...So keep responding"
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

What you add to the JMenu and the JPopupMenu are the same object; JMenuItem so you can set the accelerator.
Check out the JMenuItem API for method to set accelerator.
Recommended reading: http://download.oracle.com/javase/tutorial/uiswing/components/menu.html


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
I also want to display the accelerator keys on the menu item's label,


This works fine for me. Post your SSCCE that demonstrates the problem

Is there any way to set accelerator keys to pop up menu items.


You can try using Key Bindings. I would guess that yo would need to bind the Action to the root pane.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accelerator keys for Pop Up menu-items
 
Similar Threads
JMenu
Accelerator key for JToolBar
FBN: Acclerator Keys
Menu Items?
How to put menu item in Title bar