當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.getKeyModifiersText方法代碼示例

本文整理匯總了Java中java.awt.event.KeyEvent.getKeyModifiersText方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.getKeyModifiersText方法的具體用法?Java KeyEvent.getKeyModifiersText怎麽用?Java KeyEvent.getKeyModifiersText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.getKeyModifiersText方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findKey

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
/** Same method as above, but works just with plain actions.
 */
private static String findKey(Action action) {
    if (action == null) {
        return null;
    }

    KeyStroke accelerator = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);

    if (accelerator == null) {
        return null;
    }

    int modifiers = accelerator.getModifiers();
    String acceleratorText = ""; // NOI18N

    if (modifiers > 0) {
        acceleratorText = KeyEvent.getKeyModifiersText(modifiers);
        acceleratorText += "+"; // NOI18N
    } else if (accelerator.getKeyCode() == KeyEvent.VK_UNDEFINED) {
        return ""; // NOI18N
    }

    acceleratorText += KeyEvent.getKeyText(accelerator.getKeyCode());

    return acceleratorText;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:Actions.java

示例2: getAccText

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
private String getAccText(String acceleratorDelimiter) {
    String accText = "";
    KeyStroke accelerator = mi.getAccelerator();
    if (accelerator != null) {
        int modifiers = accelerator.getModifiers();
        if (modifiers > 0) {
            accText = KeyEvent.getKeyModifiersText(modifiers);
            accText += acceleratorDelimiter;
        }
        int keyCode = accelerator.getKeyCode();
        if (keyCode != 0) {
            accText += KeyEvent.getKeyText(keyCode);
        } else {
            accText += accelerator.getKeyChar();
        }
    }
    return accText;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:MenuItemLayoutHelper.java

示例3: getAccText

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private String getAccText(String acceleratorDelimiter) {
    String accText = "";
    KeyStroke accelerator = mi.getAccelerator();
    if (accelerator != null) {
        int modifiers = accelerator.getModifiers();
        if (modifiers > 0) {
            accText = KeyEvent.getKeyModifiersText(modifiers);
            accText += acceleratorDelimiter;
        }
        int keyCode = accelerator.getKeyCode();
        if (keyCode != 0) {
            accText += KeyEvent.getKeyText(keyCode);
        } else {
            accText += accelerator.getKeyChar();
        }
    }
    return accText;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:MenuItemLayoutHelper.java

示例4: getKeyText

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
private static String getKeyText (KeyStroke keyStroke) {
    if (keyStroke == null) return "";                       // NOI18N
    String modifText = KeyEvent.getKeyModifiersText 
        (keyStroke.getModifiers ());
    String suffix = org.openide.util.Utilities.keyToString (
            KeyStroke.getKeyStroke (keyStroke.getKeyCode (), 0)
        );
    if (suffix == null) {
        return ""; // NOI18N
    }
    if ("".equals (modifText))                              // NOI18N   
        return suffix;
    return modifText + "+" +                                // NOI18N
        suffix; 
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:MultiKeymap.java

示例5: keyStrokeToString

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
/**
 * Creates nice textual representation of KeyStroke.
 * Modifiers and an actual key label are concated by plus signs
 * @param the KeyStroke to get description of
 * @return String describing the KeyStroke
 */
public static String keyStrokeToString( KeyStroke stroke ) {
    String modifText = KeyEvent.getKeyModifiersText( stroke.getModifiers() );
    String keyText = (stroke.getKeyCode() == KeyEvent.VK_UNDEFINED) ? 
        String.valueOf(stroke.getKeyChar()) : getKeyText(stroke.getKeyCode());
    if( modifText.length() > 0 ) return modifText + '+' + keyText;
    else return keyText;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:Utilities.java

示例6: getKeyText

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
private static String getKeyText (KeyStroke keyStroke) {
    if (keyStroke == null) return "";
    String modifText = KeyEvent.getKeyModifiersText 
        (keyStroke.getModifiers ());
    if ("".equals (modifText))       
        return KeyEvent.getKeyText (keyStroke.getKeyCode ());
    return modifText + "+" +                                // NOI18N
        KeyEvent.getKeyText (keyStroke.getKeyCode ()); 
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:NbKeymap.java

示例7: findKeyBinding

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
private static String findKeyBinding(String actionName) {
    KeyBindingSettings kbs = MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(KeyBindingSettings.class); //NOI18N
    for (MultiKeyBinding mkb : kbs.getKeyBindings()) {
        if (actionName.equals(mkb.getActionName())) {
            KeyStroke ks = mkb.getKeyStrokeCount() > 0 ? mkb.getKeyStroke(0) : null;
            return ks != null ? KeyEvent.getKeyModifiersText(ks.getModifiers()) + '+' + KeyEvent.getKeyText(ks.getKeyCode()) : null;
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:ComputeAnnotations.java

示例8: keyAcceleratorString

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
public static String keyAcceleratorString(KeyStroke keyStroke) {
    if (keyStroke == null || NO_KEYSTROKE.equals(keyStroke)) return null;
    
    String keyText = KeyEvent.getKeyText(keyStroke.getKeyCode());
    
    int modifiers = keyStroke.getModifiers();
    if (modifiers == 0) return keyText;
    
    if (ACC_DELIMITER == null) {
        ACC_DELIMITER = UIManager.getString("MenuItem.acceleratorDelimiter"); // NOI18N
        if (ACC_DELIMITER == null) ACC_DELIMITER = "+"; // NOI18N // Note: NetBeans default, Swing uses '-' by default
    }
    
    return KeyEvent.getKeyModifiersText(modifiers) + ACC_DELIMITER + keyText;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ActionsSupport.java

示例9: formatKeyStroke

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
/**
 * Converts {@link KeyStroke} to a human-readable string.
 *
 * @param keyStroke
 *            the keystroke
 * @return a human-readable string like 'Ctrl+E'
 */
public static String formatKeyStroke(KeyStroke keyStroke) {
	StringBuilder builder = new StringBuilder();
	String modifierString = KeyEvent.getKeyModifiersText(keyStroke.getModifiers());
	String keyString = KeyEvent.getKeyText(keyStroke.getKeyCode());

	if (modifierString != null && !modifierString.trim().isEmpty()) {
		builder.append(modifierString);
		builder.append("+");
	}

	builder.append(keyString);

	return builder.toString();
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:22,代碼來源:SwingTools.java

示例10: setLines2and3

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
private void setLines2and3(KeyEvent event)
{
   line2 = String.format("This key is %san action key", 
      (event.isActionKey() ? "" : "not "));

   String temp = KeyEvent.getKeyModifiersText(event.getModifiers());

   line3 = String.format("Modifier keys pressed: %s", 
      (temp.equals("") ? "none" : temp)); // output modifiers

   textArea.setText(String.format("%s\n%s\n%s\n", 
      line1, line2, line3)); // output three lines of text
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:14,代碼來源:KeyDemoFrame.java

示例11: getHumanKeyStrokeText

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
/**
* Gets a string to represent the given {@code KeyStroke} to the user.
*
* @param keyStroke {@code java.awt.event.KeyStroke}
* @return String
*/
public static String getHumanKeyStrokeText(KeyStroke keyStroke) {
    if (keyStroke == null) {
        return " ";
    }

    String s = KeyEvent.getKeyModifiersText(keyStroke.getModifiers());
    if (!s.isEmpty()) s += "+";
    return s + KeyEvent.getKeyText(keyStroke.getKeyCode());
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:16,代碼來源:FreeColActionUI.java

示例12: toString

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
/**
 * Returns an internationalized description of the MenuShortcut.
 * @return a string representation of this MenuShortcut.
 * @since JDK1.1
 */
public String toString() {
    int modifiers = 0;
    if (!GraphicsEnvironment.isHeadless()) {
        modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    }
    if (usesShiftModifier()) {
        modifiers |= Event.SHIFT_MASK;
    }
    return KeyEvent.getKeyModifiersText(modifiers) + "+" +
           KeyEvent.getKeyText(key);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:MenuShortcut.java

示例13: toString

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
/**
 * Returns an internationalized description of the MenuShortcut.
 * @return a string representation of this MenuShortcut.
 * @since 1.1
 */
@SuppressWarnings("deprecation")
public String toString() {
    int modifiers = 0;
    if (!GraphicsEnvironment.isHeadless()) {
        modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    }
    if (usesShiftModifier()) {
        modifiers |= Event.SHIFT_MASK;
    }
    return KeyEvent.getKeyModifiersText(modifiers) + "+" +
           KeyEvent.getKeyText(key);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:MenuShortcut.java

示例14: toString

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
/**
 * returns String representation of shortcut
 *
 * @return String representation of shortcut
 */
@Override
public String toString() {
    String s = KeyEvent.getKeyModifiersText(getKeyModifiers());
    return s + (s.length() > 0 ? "+" : "") + KeyEvent.getKeyText(getKeyCode());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:Action.java


注:本文中的java.awt.event.KeyEvent.getKeyModifiersText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。