Java Code Examples for java.awt.event.KeyEvent#VK_CAPS_LOCK

The following examples show how to use java.awt.event.KeyEvent#VK_CAPS_LOCK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WToolkit.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    return getLockingKeyStateNative(key);
}
 
Example 2
Source File: LWCToolkit.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
    switch (keyCode) {
        case KeyEvent.VK_NUM_LOCK:
        case KeyEvent.VK_SCROLL_LOCK:
        case KeyEvent.VK_KANA_LOCK:
            throw new UnsupportedOperationException("Toolkit.getLockingKeyState");

        case KeyEvent.VK_CAPS_LOCK:
            return isCapsLockOn();

        default:
            throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
}
 
Example 3
Source File: XToolkit.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    awtLock();
    try {
        return getModifierState( key );
    } finally {
        awtUnlock();
    }
}
 
Example 4
Source File: XToolkit.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    awtLock();
    try {
        return getModifierState( key );
    } finally {
        awtUnlock();
    }
}
 
Example 5
Source File: WToolkit.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void setLockingKeyState(int key, boolean on) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
    }
    setLockingKeyStateNative(key, on);
}
 
Example 6
Source File: WToolkit.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setLockingKeyState(int key, boolean on) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
    }
    setLockingKeyStateNative(key, on);
}
 
Example 7
Source File: WToolkit.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setLockingKeyState(int key, boolean on) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
    }
    setLockingKeyStateNative(key, on);
}
 
Example 8
Source File: Config.java    From Repeat with Apache License 2.0 5 votes vote down vote up
public Config(MainBackEndHolder backEnd) {
	this.backEnd = backEnd;
	useTrayIcon = DEFAULT_TRAY_ICON_USE;
	this.enabledHaltingKeyPressed = true;
	this.executeOnKeyReleased = true;
	this.nativeHookDebugLevel = DEFAULT_NATIVE_HOOK_DEBUG_LEVEL;

	this.mouseGestureActivationKey = KeyEvent.VK_CAPS_LOCK;
	RECORD = new KeyChain(KeyEvent.VK_F9);
	REPLAY = new KeyChain(KeyEvent.VK_F11);
	COMPILED_REPLAY = new KeyChain(KeyEvent.VK_F12);
}
 
Example 9
Source File: ShortcutOptionsPanel.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Action triggered when keyboard is used.
 * 
 * @param e Event.
 * @return True if processing should end.
 * @see java.awt.KeyEventDispatcher#dispatchKeyEvent(java.awt.event.KeyEvent)
 */
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
  int key = e.getKeyCode();
  if ((key == KeyEvent.VK_ALT) ||
      (key == KeyEvent.VK_ALT_GRAPH) ||
      (key == KeyEvent.VK_BACK_SPACE) ||
      (key == KeyEvent.VK_BEGIN) ||
      (key == KeyEvent.VK_CANCEL) ||
      (key == KeyEvent.VK_CAPS_LOCK) ||
      (key == KeyEvent.VK_CONTROL) ||
      (key == KeyEvent.VK_DELETE) ||
      (key == KeyEvent.VK_DOWN) ||
      (key == KeyEvent.VK_END) ||
      (key == KeyEvent.VK_ENTER) ||
      (key == KeyEvent.VK_LEFT) ||
      (key == KeyEvent.VK_PAGE_DOWN) ||
      (key == KeyEvent.VK_PAGE_UP) ||
      (key == KeyEvent.VK_RIGHT) ||
      (key == KeyEvent.VK_SHIFT) ||
      (key == KeyEvent.VK_TAB) ||
      (key == KeyEvent.VK_UP) ||
      (key == KeyEvent.VK_SHIFT)) {
    return false;
  }
  if (key != KeyEvent.VK_ESCAPE) {
    setKeyCode(key);
  }
  showNotice(false);
  KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this);
  return false;
}
 
Example 10
Source File: WToolkit.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setLockingKeyState(int key, boolean on) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
    }
    setLockingKeyStateNative(key, on);
}
 
Example 11
Source File: WToolkit.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    return getLockingKeyStateNative(key);
}
 
Example 12
Source File: WToolkit.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    return getLockingKeyStateNative(key);
}
 
Example 13
Source File: WToolkit.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    return getLockingKeyStateNative(key);
}
 
Example 14
Source File: WToolkit.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    return getLockingKeyStateNative(key);
}
 
Example 15
Source File: LWCToolkit.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
    switch (keyCode) {
        case KeyEvent.VK_NUM_LOCK:
        case KeyEvent.VK_SCROLL_LOCK:
        case KeyEvent.VK_KANA_LOCK:
            throw new UnsupportedOperationException("Toolkit.getLockingKeyState");

        case KeyEvent.VK_CAPS_LOCK:
            return isCapsLockOn();

        default:
            throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
}
 
Example 16
Source File: ReservedKeyBindings.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public static boolean isReservedKeystroke(KeyStroke keyStroke) {
	int code = keyStroke.getKeyCode();
	if (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_ALT || code == KeyEvent.VK_CONTROL ||
		code == KeyEvent.VK_CAPS_LOCK || code == KeyEvent.VK_TAB ||
		HELP_KEY1.equals(keyStroke) || HELP_KEY2.equals(keyStroke) ||
		HELP_INFO_KEY.equals(keyStroke) || UPDATE_KEY_BINDINGS_KEY.equals(keyStroke) ||
		FOCUS_INFO_KEY.equals(keyStroke) || FOCUS_CYCLE_INFO_KEY.equals(keyStroke)) {
		return true;
	}

	return false;
}
 
Example 17
Source File: WToolkit.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    return getLockingKeyStateNative(key);
}
 
Example 18
Source File: WToolkit.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setLockingKeyState(int key, boolean on) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
    }
    setLockingKeyStateNative(key, on);
}
 
Example 19
Source File: XToolkit.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean getLockingKeyState(int key) {
    if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
           key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
    }
    awtLock();
    try {
        return getModifierState( key );
    } finally {
        awtUnlock();
    }
}
 
Example 20
Source File: Toolkit.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the state of the given locking key on the keyboard.
 * Valid key codes are
 * {@link java.awt.event.KeyEvent#VK_CAPS_LOCK VK_CAPS_LOCK},
 * {@link java.awt.event.KeyEvent#VK_NUM_LOCK VK_NUM_LOCK},
 * {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
 * {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
 * <p>
 * Depending on the platform, setting the state of a locking key may
 * involve event processing and therefore may not be immediately
 * observable through getLockingKeyState.
 *
 * @param  keyCode the key code
 * @param  on the state of the key
 * @exception java.lang.IllegalArgumentException if {@code keyCode}
 * is not one of the valid key codes
 * @exception java.lang.UnsupportedOperationException if the host system doesn't
 * allow setting the state of this key programmatically, or if the keyboard
 * doesn't have this key
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true
 * @see       java.awt.GraphicsEnvironment#isHeadless
 * @since 1.3
 */
public void setLockingKeyState(int keyCode, boolean on)
    throws UnsupportedOperationException
{
    GraphicsEnvironment.checkHeadless();

    if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK ||
           keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) {
        throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
    }
    throw new UnsupportedOperationException("Toolkit.setLockingKeyState");
}