aspose file tools*
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 Spring in Action this week in the Spring 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
Ranch Hand

Joined: Apr 08, 2010
Posts: 30

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: 10451
    
    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: 2200
    
    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