+ JMenuItem item = new JMenuItem(I18nManager.getText(inFunction.getNameKey()));
+ item.addActionListener(new FunctionLauncher(inFunction));
+ return item;
+ }
+
+ /**
+ * Set the alt key for the given menu
+ * @param inMenu menu to set
+ * @param inKey key to lookup to get language-sensitive altkey
+ */
+ private static void setAltKey(JMenu inMenu, String inKey)
+ {
+ // Lookup the key in the properties
+ String altKey = I18nManager.getText(inKey);
+ if (altKey != null && altKey.length() == 1)
+ {
+ int code = altKey.charAt(0) - 'A';
+ if (code >= 0 && code < 26)
+ {
+ // Found a valid code between A and Z
+ inMenu.setMnemonic(KEY_EVENTS[code]);
+ }
+ }
+ }
+
+ /**
+ * Set the shortcut key for the given menu item
+ * @param inMenuItem menu item to set
+ * @param inKey key to lookup to get language-sensitive shortcut
+ */
+ private static void setShortcut(JMenuItem inMenuItem, String inKey)
+ {
+ // Lookup the key in the properties
+ String altKey = I18nManager.getText(inKey);
+ if (altKey != null && altKey.length() == 1)
+ {
+ int code = altKey.charAt(0) - 'A';
+ if (code >= 0 && code < 26)
+ {
+ // Found a valid code between A and Z
+ inMenuItem.setAccelerator(KeyStroke.getKeyStroke(KEY_EVENTS[code],
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
+ // use platform-specific key mask so Ctrl on Linux/Win, Clover on Mac
+ }
+ }