Java Code Examples for java.awt.event.KeyEvent#ALT_DOWN_MASK
The following examples show how to use
java.awt.event.KeyEvent#ALT_DOWN_MASK .
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: NotCurrentlyAvailableDialogHandler.java From IBC with GNU General Public License v3.0 | 6 votes |
public void handleWindow(Window window, int eventID) { if (! SwingUtils.clickButton(window, "OK")) { Utils.logError("The system is not currently available."); return; } if (LoginManager.loginManager().getLoginFrame() != null) { JButton button2 = SwingUtils.findButton(LoginManager.loginManager().getLoginFrame(), "Login"); button2.requestFocus(); KeyEvent ke = new KeyEvent(button2, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.ALT_DOWN_MASK, KeyEvent.VK_F4, KeyEvent.CHAR_UNDEFINED); button2.dispatchEvent(ke); } }
Example 2
Source File: Utilities.java From netbeans with Apache License 2.0 | 6 votes |
private static boolean usableKeyOnMac(int key, int mask) { //All permutations fail for Q except ctrl if (key == KeyEvent.VK_Q) { return false; } boolean isMeta = ((mask & KeyEvent.META_MASK) != 0) || ((mask & KeyEvent.CTRL_DOWN_MASK) != 0); boolean isAlt = ((mask & KeyEvent.ALT_MASK) != 0) || ((mask & KeyEvent.ALT_DOWN_MASK) != 0); boolean isOnlyMeta = isMeta && ((mask & ~(KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK)) == 0); //Mac OS consumes keys Command+ these keys - the app will never see //them, so CTRL should not be remapped for these if (isOnlyMeta) { return (key != KeyEvent.VK_H) && (key != KeyEvent.VK_SPACE) && (key != KeyEvent.VK_TAB); } if ((key == KeyEvent.VK_D) && isMeta && isAlt) { return false; } if (key == KeyEvent.VK_SPACE && isMeta && ((mask & KeyEvent.CTRL_MASK) != 0)) { // http://lists.apple.com/archives/java-dev/2010/Aug/msg00002.html return false; } return true; }
Example 3
Source File: NotCurrentlyAvailableDialogHandler.java From ib-controller with GNU General Public License v3.0 | 6 votes |
public void handleWindow(Window window, int eventID) { if (! SwingUtils.clickButton(window, "OK")) { Utils.logError("The system is not currently available."); return; } if (LoginManager.loginManager().getLoginFrame() != null) { JButton button2 = SwingUtils.findButton(LoginManager.loginManager().getLoginFrame(), "Login"); button2.requestFocus(); KeyEvent ke = new KeyEvent(button2, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.ALT_DOWN_MASK, KeyEvent.VK_F4, KeyEvent.CHAR_UNDEFINED); button2.dispatchEvent(ke); } }
Example 4
Source File: CommandDispatcher.java From IBC with GNU General Public License v3.0 | 5 votes |
private void handleReconnectDataCommand() { JFrame jf = MainWindowManager.mainWindowManager().getMainWindow(1, TimeUnit.MILLISECONDS); int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; KeyEvent pressed=new KeyEvent(jf, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifiers, KeyEvent.VK_F, KeyEvent.CHAR_UNDEFINED); KeyEvent typed=new KeyEvent(jf, KeyEvent.KEY_TYPED, System.currentTimeMillis(), modifiers, KeyEvent.VK_UNDEFINED, 'F' ); KeyEvent released=new KeyEvent(jf, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), modifiers, KeyEvent.VK_F, KeyEvent.CHAR_UNDEFINED ); jf.dispatchEvent(pressed); jf.dispatchEvent(typed); jf.dispatchEvent(released); mChannel.writeAck(""); }
Example 5
Source File: CommandDispatcher.java From IBC with GNU General Public License v3.0 | 5 votes |
private void handleReconnectAccountCommand() { JFrame jf = MainWindowManager.mainWindowManager().getMainWindow(); int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; KeyEvent pressed=new KeyEvent(jf, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifiers, KeyEvent.VK_R, KeyEvent.CHAR_UNDEFINED); KeyEvent typed=new KeyEvent(jf, KeyEvent.KEY_TYPED, System.currentTimeMillis(), modifiers, KeyEvent.VK_UNDEFINED, 'R' ); KeyEvent released=new KeyEvent(jf, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), modifiers, KeyEvent.VK_R, KeyEvent.CHAR_UNDEFINED ); jf.dispatchEvent(pressed); jf.dispatchEvent(typed); jf.dispatchEvent(released); mChannel.writeAck(""); }
Example 6
Source File: MainUtils.java From PhotonFileValidator with MIT License | 5 votes |
public static int getSystemDefaultModifierMask() { int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); if (mask == Event.META_MASK) { return KeyEvent.META_DOWN_MASK; } else if (mask == Event.ALT_MASK) { return KeyEvent.ALT_DOWN_MASK; } return KeyEvent.CTRL_DOWN_MASK; }
Example 7
Source File: HotKeyAction.java From netbeans with Apache License 2.0 | 5 votes |
public State keyTyped (Widget widget, WidgetKeyEvent event) { if (event.getModifiersEx() == (KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK) && provider.processHotKey(widget, event.getKeyChar())) { return State.CONSUMED; } return super.keyTyped(widget, event); }
Example 8
Source File: KeyMapOperator.java From netbeans with Apache License 2.0 | 5 votes |
private int buildKeyModifierMask(boolean ctrl, boolean alt, boolean shift) { int _mask = 0; if (ctrl) { _mask = _mask | KeyEvent.CTRL_DOWN_MASK; } if (alt) { _mask = _mask | KeyEvent.ALT_DOWN_MASK; } if (shift) { _mask = _mask | KeyEvent.SHIFT_DOWN_MASK; } return _mask; }
Example 9
Source File: CommandDispatcher.java From ib-controller with GNU General Public License v3.0 | 5 votes |
private void handleReconnectDataCommand() { JFrame jf = MainWindowManager.mainWindowManager().getMainWindow(1, TimeUnit.MILLISECONDS); int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; KeyEvent pressed=new KeyEvent(jf, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifiers, KeyEvent.VK_F, KeyEvent.CHAR_UNDEFINED); KeyEvent typed=new KeyEvent(jf, KeyEvent.KEY_TYPED, System.currentTimeMillis(), modifiers, KeyEvent.VK_UNDEFINED, 'F' ); KeyEvent released=new KeyEvent(jf, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), modifiers, KeyEvent.VK_F, KeyEvent.CHAR_UNDEFINED ); jf.dispatchEvent(pressed); jf.dispatchEvent(typed); jf.dispatchEvent(released); mChannel.writeAck(""); }
Example 10
Source File: CommandDispatcher.java From ib-controller with GNU General Public License v3.0 | 5 votes |
private void handleReconnectAccountCommand() { JFrame jf = MainWindowManager.mainWindowManager().getMainWindow(); int modifiers = KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK; KeyEvent pressed=new KeyEvent(jf, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifiers, KeyEvent.VK_R, KeyEvent.CHAR_UNDEFINED); KeyEvent typed=new KeyEvent(jf, KeyEvent.KEY_TYPED, System.currentTimeMillis(), modifiers, KeyEvent.VK_UNDEFINED, 'R' ); KeyEvent released=new KeyEvent(jf, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), modifiers, KeyEvent.VK_R, KeyEvent.CHAR_UNDEFINED ); jf.dispatchEvent(pressed); jf.dispatchEvent(typed); jf.dispatchEvent(released); mChannel.writeAck(""); }
Example 11
Source File: MenuBar.java From netbeans with Apache License 2.0 | 4 votes |
protected @Override boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { if (Utilities.isMac()) { int mods = e.getModifiers(); boolean isCtrl = (mods & KeyEvent.CTRL_MASK) != 0; boolean isAlt = (mods & KeyEvent.ALT_MASK) != 0; if (isAlt && (e instanceof MarkedKeyEvent)) { mods = mods & ~ KeyEvent.CTRL_MASK; mods = mods & ~ KeyEvent.CTRL_DOWN_MASK; mods |= KeyEvent.ALT_MASK; mods |= KeyEvent.ALT_DOWN_MASK; KeyEvent newEvent = new MarkedKeyEvent ( (Component) e.getSource(), e.getID(), e.getWhen(), mods, e.getKeyCode(), e.getKeyChar(), e.getKeyLocation()); KeyStroke newStroke = null; if( null != ks ) { newStroke = e.getID() == KeyEvent.KEY_TYPED ? KeyStroke.getKeyStroke (ks.getKeyChar(), mods) : KeyStroke.getKeyStroke (ks.getKeyCode(), mods, !ks.isOnKeyRelease()); } boolean result = super.processKeyBinding (newStroke, newEvent, condition, pressed); if (newEvent.isConsumed()) { e.consume(); } return result; } else if (!isAlt) { return super.processKeyBinding (ks, e, condition, pressed); } else { return false; } } else { return super.processKeyBinding (ks, e, condition, pressed); } }