java.awt.event.KeyEvent#VK_UNDEFINED源码实例Demo

下面列出了java.awt.event.KeyEvent#VK_UNDEFINED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u_jdk   文件: ExtendedKeyCodes.java
final public static int getExtendedKeyCodeForChar( int c ) {
    int uc = Character.toUpperCase( c );
    int lc = Character.toLowerCase( c );
    if (regularKeyCodesMap.containsKey( c )) {
        if(regularKeyCodesMap.containsKey(uc)) {
            return regularKeyCodesMap.get( uc );
        }
        return regularKeyCodesMap.get( c );
    }
    uc += 0x01000000;
    lc += 0x01000000;
    if (extendedKeyCodesSet.contains( uc )) {
        return uc;
    }else if (extendedKeyCodesSet.contains( lc )) {
        return lc;
    }
    return KeyEvent.VK_UNDEFINED;
}
 
源代码2 项目: jdk8u-dev-jdk   文件: Robot.java
private void checkKeycodeArgument(int keycode) {
    // rather than build a big table or switch statement here, we'll
    // just check that the key isn't VK_UNDEFINED and assume that the
    // peer implementations will throw an exception for other bogus
    // values e.g. -1, 999999
    if (keycode == KeyEvent.VK_UNDEFINED) {
        throw new IllegalArgumentException("Invalid key code");
    }
}
 
源代码3 项目: openjdk-jdk9   文件: MetaData.java
protected Expression instantiate(Object oldInstance, Encoder out) {
    AWTKeyStroke key = (AWTKeyStroke) oldInstance;

    char ch = key.getKeyChar();
    int code = key.getKeyCode();
    int mask = key.getModifiers();
    boolean onKeyRelease = key.isOnKeyRelease();

    Object[] args = null;
    if (ch == KeyEvent.CHAR_UNDEFINED) {
        args = !onKeyRelease
                ? new Object[]{code, mask}
                : new Object[]{code, mask, onKeyRelease};
    } else if (code == KeyEvent.VK_UNDEFINED) {
        if (!onKeyRelease) {
            args = (mask == 0)
                    ? new Object[]{ch}
                    : new Object[]{ch, mask};
        } else if (mask == 0) {
            args = new Object[]{ch, onKeyRelease};
        }
    }
    if (args == null) {
        throw new IllegalStateException("Unsupported KeyStroke: " + key);
    }
    Class<?> type = key.getClass();
    String name = type.getName();
    // get short name of the class
    int index = name.lastIndexOf('.') + 1;
    if (index > 0) {
        name = name.substring(index);
    }
    return new Expression( key, type, "get" + name, args );
}
 
源代码4 项目: jdk8u-jdk   文件: AWTKeyStroke.java
/**
 * Returns the type of <code>KeyEvent</code> which corresponds to
 * this <code>AWTKeyStroke</code>.
 *
 * @return <code>KeyEvent.KEY_PRESSED</code>,
 *         <code>KeyEvent.KEY_TYPED</code>,
 *         or <code>KeyEvent.KEY_RELEASED</code>
 * @see java.awt.event.KeyEvent
 */
public final int getKeyEventType() {
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return KeyEvent.KEY_TYPED;
    } else {
        return (onKeyRelease)
            ? KeyEvent.KEY_RELEASED
            : KeyEvent.KEY_PRESSED;
    }
}
 
源代码5 项目: openjdk-jdk9   文件: DefaultCharBindingMap.java
/**
 * Returns key + modifiers pair.
 *
 * @param c Symbol code.
 * @return an array of two elements: key code and modifiers mask - a
 * combination of InputEvent MASK fields.
 */
public int[] getKeyAndModifiers(char c) {
    CharKey key = chars.get(c);
    if (key != null) {
        return new int[]{key.key, key.modifiers};
    } else {
        return new int[]{KeyEvent.VK_UNDEFINED, 0};
    }
}
 
源代码6 项目: openjdk-jdk8u-backup   文件: AWTKeyStroke.java
/**
 * Returns the type of <code>KeyEvent</code> which corresponds to
 * this <code>AWTKeyStroke</code>.
 *
 * @return <code>KeyEvent.KEY_PRESSED</code>,
 *         <code>KeyEvent.KEY_TYPED</code>,
 *         or <code>KeyEvent.KEY_RELEASED</code>
 * @see java.awt.event.KeyEvent
 */
public final int getKeyEventType() {
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return KeyEvent.KEY_TYPED;
    } else {
        return (onKeyRelease)
            ? KeyEvent.KEY_RELEASED
            : KeyEvent.KEY_PRESSED;
    }
}
 
源代码7 项目: JDKSourceCode1.8   文件: AWTKeyStroke.java
/**
 * Returns a string that displays and identifies this object's properties.
 * The <code>String</code> returned by this method can be passed
 * as a parameter to <code>getAWTKeyStroke(String)</code> to produce
 * a key stroke equal to this key stroke.
 *
 * @return a String representation of this object
 * @see #getAWTKeyStroke(String)
 */
public String toString() {
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return getModifiersText(modifiers) + "typed " + keyChar;
    } else {
        return getModifiersText(modifiers) +
            (onKeyRelease ? "released" : "pressed") + " " +
            getVKText(keyCode);
    }
}
 
源代码8 项目: marathonv5   文件: OSUtils.java
private static CharSequence getKeys(String keysFor, String sKeyStroke) {
    KeyStroke ks = KeyStroke.getKeyStroke(sKeyStroke);
    if (ks == null) {
        throw new WebDriverException("Unable to parse keystroke for " + keysFor + " trying to parse " + sKeyStroke);
    }
    StringBuilder sb = new StringBuilder();
    int modifiers = ks.getModifiers();
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK) {
        sb.append(Keys.CONTROL);
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) == InputEvent.ALT_DOWN_MASK) {
        sb.append(Keys.ALT);
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) == InputEvent.META_DOWN_MASK) {
        sb.append(Keys.META);
    }
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK) {
        sb.append(Keys.SHIFT);
    }
    int keyCode = ks.getKeyCode();
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        sb.append(ks.getKeyChar());
    } else {
        sb.append(keyCharFromKeyCode(keyCode, keysFor));
    }
    sb.append(Keys.NULL);
    return sb.toString();
}
 
源代码9 项目: Java8CN   文件: Robot.java
private void checkKeycodeArgument(int keycode) {
    // rather than build a big table or switch statement here, we'll
    // just check that the key isn't VK_UNDEFINED and assume that the
    // peer implementations will throw an exception for other bogus
    // values e.g. -1, 999999
    if (keycode == KeyEvent.VK_UNDEFINED) {
        throw new IllegalArgumentException("Invalid key code");
    }
}
 
源代码10 项目: jdk-1.7-annotated   文件: Robot.java
private void checkKeycodeArgument(int keycode) {
    // rather than build a big table or switch statement here, we'll
    // just check that the key isn't VK_UNDEFINED and assume that the
    // peer implementations will throw an exception for other bogus
    // values e.g. -1, 999999
    if (keycode == KeyEvent.VK_UNDEFINED) {
        throw new IllegalArgumentException("Invalid key code");
    }
}
 
源代码11 项目: jdk8u-jdk   文件: MetaData.java
protected Expression instantiate(Object oldInstance, Encoder out) {
    AWTKeyStroke key = (AWTKeyStroke) oldInstance;

    char ch = key.getKeyChar();
    int code = key.getKeyCode();
    int mask = key.getModifiers();
    boolean onKeyRelease = key.isOnKeyRelease();

    Object[] args = null;
    if (ch == KeyEvent.CHAR_UNDEFINED) {
        args = !onKeyRelease
                ? new Object[]{code, mask}
                : new Object[]{code, mask, onKeyRelease};
    } else if (code == KeyEvent.VK_UNDEFINED) {
        if (!onKeyRelease) {
            args = (mask == 0)
                    ? new Object[]{ch}
                    : new Object[]{ch, mask};
        } else if (mask == 0) {
            args = new Object[]{ch, onKeyRelease};
        }
    }
    if (args == null) {
        throw new IllegalStateException("Unsupported KeyStroke: " + key);
    }
    Class<?> type = key.getClass();
    String name = type.getName();
    // get short name of the class
    int index = name.lastIndexOf('.') + 1;
    if (index > 0) {
        name = name.substring(index);
    }
    return new Expression( key, type, "get" + name, args );
}
 
源代码12 项目: jdk8u_jdk   文件: InputContext.java
private AWTKeyStroke getInputMethodSelectionKeyStroke(Preferences root) {
    try {
        if (root.nodeExists(inputMethodSelectionKeyPath)) {
            Preferences node = root.node(inputMethodSelectionKeyPath);
            int keyCode = node.getInt(inputMethodSelectionKeyCodeName, KeyEvent.VK_UNDEFINED);
            if (keyCode != KeyEvent.VK_UNDEFINED) {
                int modifiers = node.getInt(inputMethodSelectionKeyModifiersName, 0);
                return AWTKeyStroke.getAWTKeyStroke(keyCode, modifiers);
            }
        }
    } catch (BackingStoreException bse) {
    }

    return null;
}
 
源代码13 项目: jdk8u60   文件: Robot.java
private void checkKeycodeArgument(int keycode) {
    // rather than build a big table or switch statement here, we'll
    // just check that the key isn't VK_UNDEFINED and assume that the
    // peer implementations will throw an exception for other bogus
    // values e.g. -1, 999999
    if (keycode == KeyEvent.VK_UNDEFINED) {
        throw new IllegalArgumentException("Invalid key code");
    }
}
 
源代码14 项目: hottub   文件: Robot.java
private void checkKeycodeArgument(int keycode) {
    // rather than build a big table or switch statement here, we'll
    // just check that the key isn't VK_UNDEFINED and assume that the
    // peer implementations will throw an exception for other bogus
    // values e.g. -1, 999999
    if (keycode == KeyEvent.VK_UNDEFINED) {
        throw new IllegalArgumentException("Invalid key code");
    }
}
 
源代码15 项目: jdk-1.7-annotated   文件: AWTKeyStroke.java
/**
 * Returns the type of <code>KeyEvent</code> which corresponds to
 * this <code>AWTKeyStroke</code>.
 *
 * @return <code>KeyEvent.KEY_PRESSED</code>,
 *         <code>KeyEvent.KEY_TYPED</code>,
 *         or <code>KeyEvent.KEY_RELEASED</code>
 * @see java.awt.event.KeyEvent
 */
public final int getKeyEventType() {
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return KeyEvent.KEY_TYPED;
    } else {
        return (onKeyRelease)
            ? KeyEvent.KEY_RELEASED
            : KeyEvent.KEY_PRESSED;
    }
}
 
源代码16 项目: openjdk-jdk8u   文件: AWTKeyStroke.java
/**
 * Returns a string that displays and identifies this object's properties.
 * The <code>String</code> returned by this method can be passed
 * as a parameter to <code>getAWTKeyStroke(String)</code> to produce
 * a key stroke equal to this key stroke.
 *
 * @return a String representation of this object
 * @see #getAWTKeyStroke(String)
 */
public String toString() {
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return getModifiersText(modifiers) + "typed " + keyChar;
    } else {
        return getModifiersText(modifiers) +
            (onKeyRelease ? "released" : "pressed") + " " +
            getVKText(keyCode);
    }
}
 
源代码17 项目: jdk8u-jdk   文件: AWTKeyStroke.java
/**
 * Returns a string that displays and identifies this object's properties.
 * The <code>String</code> returned by this method can be passed
 * as a parameter to <code>getAWTKeyStroke(String)</code> to produce
 * a key stroke equal to this key stroke.
 *
 * @return a String representation of this object
 * @see #getAWTKeyStroke(String)
 */
public String toString() {
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return getModifiersText(modifiers) + "typed " + keyChar;
    } else {
        return getModifiersText(modifiers) +
            (onKeyRelease ? "released" : "pressed") + " " +
            getVKText(keyCode);
    }
}
 
源代码18 项目: RemoteSupportTool   文件: StaffApplication.java
@Override
@SuppressWarnings("Duplicates")
protected synchronized void doHandleKeyPress(KeyEvent e) {
    if (handler == null) return;
    //LOGGER.debug("key pressed: " + e.paramString());

    // Get code of the pressed key.
    // Keypad arrows are translated to regular arrow keys.
    final int keyCode;
    switch (e.getKeyCode()) {
        case KeyEvent.VK_KP_DOWN:
            keyCode = KeyEvent.VK_DOWN;
            break;
        case KeyEvent.VK_KP_LEFT:
            keyCode = KeyEvent.VK_LEFT;
            break;
        case KeyEvent.VK_KP_RIGHT:
            keyCode = KeyEvent.VK_RIGHT;
            break;
        case KeyEvent.VK_KP_UP:
            keyCode = KeyEvent.VK_UP;
            break;
        default:
            keyCode = e.getKeyCode();
            break;
    }

    // Never press undefined key codes.
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return;
    }

    // Never send caps lock, num lock and scroll lock key.
    if (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || keyCode == KeyEvent.VK_SCROLL_LOCK) {
        return;
    }

    // Detect, if a control key was pressed.
    final boolean isControlKey = e.isActionKey() ||
            keyCode == KeyEvent.VK_BACK_SPACE ||
            keyCode == KeyEvent.VK_DELETE ||
            keyCode == KeyEvent.VK_ENTER ||
            keyCode == KeyEvent.VK_SPACE ||
            keyCode == KeyEvent.VK_TAB ||
            keyCode == KeyEvent.VK_ESCAPE ||
            keyCode == KeyEvent.VK_ALT ||
            keyCode == KeyEvent.VK_ALT_GRAPH ||
            keyCode == KeyEvent.VK_CONTROL ||
            keyCode == KeyEvent.VK_SHIFT ||
            keyCode == KeyEvent.VK_META;

    // Press control keys.
    if (isControlKey) {
        //LOGGER.debug("press key \"{}\" ({})", keyCode, KeyEvent.getKeyText(keyCode));
        handler.sendKeyPress(keyCode);
        e.consume();
    }

    // Press other keys, if they are pressed together with a modifier key.
    else if (e.isControlDown() || e.isMetaDown() || windowsKeyDown || (!SystemUtils.IS_OS_MAC && e.isAltDown())) {
        //LOGGER.debug("press key \"{}\" ({})", keyCode, KeyEvent.getKeyText(keyCode));
        handler.sendKeyPress(keyCode);
        if (!pressedKeys.contains(keyCode))
            pressedKeys.add(keyCode);
        e.consume();
    }

    // Remember, that the Windows key was pressed.
    if (keyCode == KeyEvent.VK_WINDOWS) {
        synchronized (Frame.this) {
            windowsKeyDown = true;
        }
    }
}
 
源代码19 项目: Bytecoder   文件: InputMethodContext.java
/**
 * Dispatches committed text to a client component.
 * Called by composition window.
 *
 * @param client The component that the text should get dispatched to.
 * @param text The iterator providing access to the committed
 *        (and possible composed) text.
 * @param committedCharacterCount The number of committed characters in the text.
 */
synchronized void dispatchCommittedText(Component client,
             AttributedCharacterIterator text,
             int committedCharacterCount) {
    // note that the client is not always the current client component -
    // some host input method adapters may dispatch input method events
    // through the Java event queue, and we may have switched clients while
    // the event was in the queue.
    if (committedCharacterCount == 0
            || text.getEndIndex() <= text.getBeginIndex()) {
        return;
    }
    long time = System.currentTimeMillis();
    dispatchingCommittedText = true;
    try {
        InputMethodRequests req = client.getInputMethodRequests();
        if (req != null) {
            // active client -> send text as InputMethodEvent
            int beginIndex = text.getBeginIndex();
            AttributedCharacterIterator toBeCommitted =
                (new AttributedString(text, beginIndex, beginIndex + committedCharacterCount)).getIterator();

            InputMethodEvent inputEvent = new InputMethodEvent(
                    client,
                    InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                    toBeCommitted,
                    committedCharacterCount,
                    null, null);

            client.dispatchEvent(inputEvent);
        } else {
            // passive client -> send text as KeyEvents
            char keyChar = text.first();
            while (committedCharacterCount-- > 0 && keyChar != CharacterIterator.DONE) {
                KeyEvent keyEvent = new KeyEvent(client, KeyEvent.KEY_TYPED,
                                             time, 0, KeyEvent.VK_UNDEFINED, keyChar);
                client.dispatchEvent(keyEvent);
                keyChar = text.next();
            }
        }
    } finally {
        dispatchingCommittedText = false;
    }
}
 
源代码20 项目: jdk8u-jdk   文件: KeyStroke.java
/**
 * Returns an instance of a KeyStroke, specifying whether the key is
 * considered to be activated when it is pressed or released. Unlike all
 * other factory methods in this class, the instances returned by this
 * method are not necessarily cached or shared.
 *
 * @param keyChar the character value for a keyboard key
 * @param onKeyRelease <code>true</code> if this KeyStroke corresponds to a
 *        key release; <code>false</code> otherwise.
 * @return a KeyStroke object for that key
 * @deprecated use getKeyStroke(char)
 */
@Deprecated
public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease) {
    return new KeyStroke(keyChar, KeyEvent.VK_UNDEFINED, 0, onKeyRelease);
}