This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum 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
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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: 8566

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


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

Joined: Jun 13, 2009
Posts: 1808
    
    2
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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Accelerator keys for Pop Up menu-items
 
Similar Threads
JMenu
FBN: Acclerator Keys
How to put menu item in Title bar
Accelerator key for JToolBar
Menu Items?