Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Accelerator keys for Pop Up menu-items

 
Ranch Hand
Posts: 33
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 3140
27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
He baked a muffin that stole my car! And this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!