private static String getModifiersText(@JdkConstants.InputEventMask int modifiers) { if (SystemInfo.isMac) { // try { // Class appleLaf = Class.forName(APPLE_LAF_AQUA_LOOK_AND_FEEL_CLASS_NAME); // Method getModifiers = appleLaf.getMethod(GET_KEY_MODIFIERS_TEXT_METHOD, int.class, // boolean.class); // return (String)getModifiers.invoke(appleLaf, modifiers, Boolean.FALSE); // } // catch (Exception e) { // if (SystemInfo.isMacOSLeopard) { // return getKeyModifiersTextForMacOSLeopard(modifiers); // } // // // OK do nothing here. // } return MacKeymapUtil.getModifiersText(modifiers); } final String keyModifiersText = KeyEvent.getKeyModifiersText(modifiers); if (keyModifiersText.isEmpty()) { return keyModifiersText; } else { return keyModifiersText + "+"; } }
public static String getKeystrokeText(KeyStroke accelerator) { if (accelerator == null) return ""; if (SystemInfo.isMac) { return MacKeymapUtil.getKeyStrokeText(accelerator); } String acceleratorText = ""; int modifiers = accelerator.getModifiers(); if (modifiers > 0) { acceleratorText = getModifiersText(modifiers); } final int code = accelerator.getKeyCode(); String keyText = SystemInfo.isMac ? MacKeymapUtil.getKeyText(code) : KeyEvent.getKeyText(code); // [vova] this is dirty fix for bug #35092 if (CANCEL_KEY_TEXT.equals(keyText)) { keyText = BREAK_KEY_TEXT; } acceleratorText += keyText; return acceleratorText.trim(); }