Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add a Shortcut to menu or menuItem  RSS feed

 
Iftikhar Arain
Ranch Hand
Posts: 95
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one tell me how to add a menu or menuitem shortcut in awt gui.
Please give me a example or any link where a i can found a example.
Thanks in Advanced
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java tutorial : How to use Menus
...Moving this to Swing/JFC/AWT
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the method JMenuItem.setAccelerator(KeyStroke)
this method will add the shortcut string to the menuitem and trigger the action that is a attached to your menuitem.
cheers
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:roll:
MenuItem.setShortcut(MenuShortcut)
 
Iftikhar Arain
Ranch Hand
Posts: 95
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chantal Ackermann please give me the example in AWT not in Swing for shortcutmenu.
I have already used the method of
MenuItem.setShortcut(MenuShortcut);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!