How can I create internationalized accelerator keys (not mnemonics) for menu items? (The same menu item could have different accelerator keys for different languages.)
Use the following API
as in the following code:
public static KeyStroke getKeyStroke(String s)
"<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.