• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting Short cut Keys For Menus

 
sathish gopal
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have Created a Menu Called File.I have added new,open,save to
Menu File.Now I Want to Set Keyboard Shortcut For Menu File
(for example Alt+F Should Open File Menu and Pressing 'O' Should Open A new File .Like ShortCuts in DOSEditor and notepad)

Thank u in Advance
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to create a Key Listener, and listen for the KeyEvent when the Alt and the F are pressed together, then you can fire off whatever code you want.
This is a tutorial on how to create a Key Listener:
http://java.sun.com/j2se/1.3/docs/api/index.html
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Swing, you also have the option of
myMenu.setMnemonic( 'F' ) ;
If you are using AWT, try setShortcut() from MenuItem.
Hope this helps.
Stephanie
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!