当前位置: 首页>>代码示例>>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;未经允许,请勿转载。