Example usage for java.awt.event KeyEvent VK_UNDEFINED

List of usage examples for java.awt.event KeyEvent VK_UNDEFINED

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_UNDEFINED.

Prototype

int VK_UNDEFINED

To view the source code for java.awt.event KeyEvent VK_UNDEFINED.

Click Source Link

Document

This value is used to indicate that the keyCode is unknown.

Usage

From source file:org.eclipse.wb.internal.swing.model.property.editor.accelerator.KeyStrokePropertyEditor.java

/**
 * @return the textual presentation of given {@link KeyStroke}.
 *///  w ww  .  ja v a 2  s  . c om
private static String getText(KeyStroke stroke) {
    try {
        // prepare modifiers
        String modifiersText = "";
        {
            int modifiers = stroke.getModifiers();
            if ((modifiers & CTRL_MASK) != 0) {
                modifiersText += "Ctrl+";
            }
            if ((modifiers & ALT_MASK) != 0) {
                modifiersText += "Alt+";
            }
            if ((modifiers & SHIFT_MASK) != 0) {
                modifiersText += "Shift+";
            }
            if ((modifiers & META_MASK) != 0) {
                modifiersText += "Meta+";
            }
            if ((modifiers & ALT_GRAPH_MASK) != 0) {
                modifiersText += "AltGr+";
            }
            // remove trailing '+'
            if (modifiersText.length() != 0) {
                modifiersText = StringUtils.substring(modifiersText, 0, -1);
            }
        }
        // add key
        int keyCode = stroke.getKeyCode();
        if (keyCode != KeyEvent.VK_UNDEFINED) {
            return modifiersText + "-" + getKeyName(keyCode);
        }
        // no key
        return modifiersText;
    } catch (Throwable e) {
        DesignerPlugin.log(e);
    }
    return null;
}

From source file:org.eclipse.wb.internal.swing.model.property.editor.accelerator.KeyStrokePropertyEditor.java

/**
 * @return the code of key with given name.
 *///from   ww  w. j  a v a2s  .co m
private static int getKeyCode(String keyName) {
    prepareKeyMaps();
    Integer value = m_keyNameToCode.get(keyName);
    if (value != null) {
        return value.intValue();
    }
    return KeyEvent.VK_UNDEFINED;
}