Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setAccelerator  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a File Menu with Several Choices. Two of them being an Import and and Export. Then I have submenus under both Import and export most of the options are the same. i.e.
Import --> SQL, Access, Text
Export --> SQL, Access, Text
What I would like to do is set accelerator keys like this.
Import -> SQL -> CTRL + F1
Export -> SQL -> CTRL + SHIFT + F1
I know how to do the first. Any ideas on how to do the second?
Thanks

------------------
Happy Coding,
Gregg Bolinger
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind, figured this one out too.

------------------
Happy Coding,
Gregg Bolinger
 
Sudha Lakshman
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gregg Bolinger:
Nevermind, figured this one out too.

Can you let me know how you figured this out. Also, I wanted to know how to change the font of the accelerator "CTRL+SHIFT+E" etc to the same font as that of the JMenuItem.
thanks and regards, Sudha
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use
meenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke('E', java.awt.event.KeyEvent.CTRL_MASK | java.awt.event.KeyEvent.SHIFT_MASK, false));
I think accelerator will have the same font as the menu item.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!