
-----------------------------------
copthesaint
Fri May 27, 2011 3:03 pm

Java Menu Action Masks
-----------------------------------
Im just wondering, When you create a menu item, eg:

menuItem = new JMenuItem("Launch", KeyEvent.VK_A); 
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); //Important line of code :)
menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything yet");
menu.add(menuItem);

What can I use just to set the accelerator as 'A' for example. without a meta, Shift Crtl mask.

-----------------------------------
Tony
Fri May 27, 2011 3:22 pm

RE:Java Menu Action Masks
-----------------------------------
http://download.oracle.com/javase/6/docs/api/javax/swing/KeyStroke.html

-----------------------------------
copthesaint
Sat May 28, 2011 12:37 am

RE:Java Menu Action Masks
-----------------------------------
Doesnt help me, already looked at page before I posted this. Bump
How would I do this for F1?

-----------------------------------
Tony
Sat May 28, 2011 1:07 am

Re: Java Menu Action Masks
-----------------------------------
so you are using
What can I use just to set the accelerator as 'A' for example. without a meta, Shift Crtl mask.
and so the linked page also specifies
[code]
static KeyStroke	getKeyStroke(char keyChar) 
          Returns a shared instance of a KeyStroke that represents a KEY_TYPED event for the specified character.
[/code]

unless I'm misinterpreting something...

-----------------------------------
copthesaint
Sun May 29, 2011 4:31 pm

Re: Java Menu Action Masks
-----------------------------------
No I was using getKeyStroke(int keyCode, int modifiers) but now looking at it I thought "I bet this is an extremly easy problem to fix if I check KeyEvent" surly enough super easy: getKeyText(int keyCode)  So I fixed it from 
 
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
//too
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.getKeyText(KeyEvent.VK_A)));

I need to pay more attention -_-. thnx for helping anyways :) I found my answer from what u said.
