How can I create internationalized accelerator keys (not mnemonics) for menu items? (The same menu item could have different accelerator keys for different languages.)

Sandip Chitale

Use the following API

KeyStroke.getKeyStroke(String stringFormOfKeyStroke)

as in the following code:

public static KeyStroke getKeyStroke(String s)

Parse a string with the following syntax and return an a KeyStroke:
"<modifiers>* <key>"
modifiers := shift | control | meta | alt | button1 | button2 | button3
key := KeyEvent keycode name, i.e. the name following "VK_".

Here are some examples:

"INSERT" => new KeyStroke(0, KeyEvent.VK_INSERT);
"control DELETE" => new KeyStroke(InputEvent.CTRL_MASK, KeyEvent.VK_DELETE);
"alt shift X" => new KeyStroke(InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, KeyEvent.VK_X);

Now, it becomes a matter of loading a locale based ResourceBundle which contains the map. For details on ResourceBundle please see the following URL -


To keep the uniqueness of the key is the responsibility of the person who localizes the resource bundle. You could write a GUI to wrap that functionality.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.