Java Code Examples for java.awt.event.KeyEvent#isControlDown()
The following examples show how to use
java.awt.event.KeyEvent#isControlDown() .
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: KeyGetter.java From tn5250j with GNU General Public License v2.0 | 6 votes |
void processVTKeyTyped(KeyEvent e){ displayInfo(e); int keycode = e.getKeyCode(); if (e.isAltDown() || e.isShiftDown() || e.isControlDown() || e.isActionKey() || keycode == KeyEvent.VK_CONTROL) { keyevent = e; // displayInfo(e,"Released added "); dialog.setVisible(false); dialog.dispose(); } }
Example 2
Source File: GUILabelingTool.java From Pixie with MIT License | 6 votes |
/** * Handles the keys which have the same functionality for all the types * of labeling. */ private void dispatchKeyGeneral(KeyEvent e) { int eventId = e.getID(); int key = e.getKeyCode(); // the mapping of the keys is based on the default assignment of keys for UGEE graphic tablet if (eventId == KeyEvent.KEY_PRESSED) { if (e.isControlDown()) { handleCtrlKey(key); } else if (e.isAltDown()) { handleAltKey(key); } else { handleNormalKey(key); } } }
Example 3
Source File: Search.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
private void tryCloseTab(KeyEvent ke) { switch (ke.getKeyCode()) { case KeyEvent.VK_W: if (!ke.isControlDown()) return; int ntabs = search_tabs.getTabCount(); if (0 == ntabs) { instance.destroy(); return; } search_tabs.remove(search_tabs.getSelectedIndex()); return; default: return; } }
Example 4
Source File: KeyStroker.java From tn5250j with GNU General Public License v2.0 | 6 votes |
public void setAttributes(KeyEvent ke, boolean isAltGr) { keyCode = ke.getKeyCode(); isShiftDown = ke.isShiftDown(); isControlDown = ke.isControlDown(); isAltDown = ke.isAltDown(); isAltGrDown = isAltGr; location = ke.getKeyLocation(); hashCode = keyCode + (isShiftDown ? 1 : 0) + (isControlDown ? 1 : 0) + (isAltDown ? 1 : 0) + (isAltGrDown ? 1 : 0) + location; }
Example 5
Source File: Ruler.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { int step = e.isControlDown() ? 50 : e.isAltDown() ? 1 : 5; switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: setLocation(getX() - step, getY()); break; case KeyEvent.VK_RIGHT: setLocation(getX() + step, getY()); break; case KeyEvent.VK_UP: setLocation(getX(), getY() - step); break; case KeyEvent.VK_DOWN: setLocation(getX(), getY() + step); break; case KeyEvent.VK_ESCAPE: exitAction.actionPerformed(null); } }
Example 6
Source File: StaffApplication.java From RemoteSupportTool with Apache License 2.0 | 6 votes |
@Override protected synchronized void doHandleKeyTyped(KeyEvent e) { if (handler == null) return; //LOGGER.debug("key typed: " + e.paramString()); final char keyChar = e.getKeyChar(); // Don't type non printable characters. if (keyChar == KeyEvent.CHAR_UNDEFINED || Character.isWhitespace(keyChar) || Character.isISOControl(keyChar) || Character.isIdentifierIgnorable(keyChar)) { //LOGGER.debug("non printable {} / {}", Character.isWhitespace(keyChar), Character.isISOControl(keyChar)); return; } // Don't type a character, if a modifier key is pressed at the same time. if (e.isControlDown() || e.isMetaDown() || windowsKeyDown || (!SystemUtils.IS_OS_MAC && e.isAltDown())) { //LOGGER.debug("modifier {} / {} / {} / {}", e.isControlDown(), e.isAltDown(), e.isMetaDown(), windowsKeyDown); return; } //LOGGER.debug("type character \"{}\" ({})", keyChar, e.getKeyCode()); handler.sendKeyType(keyChar); e.consume(); }
Example 7
Source File: Ruler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { int step = e.isControlDown() ? 50 : e.isAltDown() ? 1 : 5; switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: setLocation(getX() - step, getY()); break; case KeyEvent.VK_RIGHT: setLocation(getX() + step, getY()); break; case KeyEvent.VK_UP: setLocation(getX(), getY() - step); break; case KeyEvent.VK_DOWN: setLocation(getX(), getY() + step); break; case KeyEvent.VK_ESCAPE: exitAction.actionPerformed(null); } }
Example 8
Source File: Ruler.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { int step = e.isControlDown() ? 50 : e.isAltDown() ? 1 : 5; switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: setLocation(getX() - step, getY()); break; case KeyEvent.VK_RIGHT: setLocation(getX() + step, getY()); break; case KeyEvent.VK_UP: setLocation(getX(), getY() - step); break; case KeyEvent.VK_DOWN: setLocation(getX(), getY() + step); break; case KeyEvent.VK_ESCAPE: exitAction.actionPerformed(null); } }
Example 9
Source File: KeyStroker.java From tn5250j with GNU General Public License v2.0 | 6 votes |
public KeyStroker(KeyEvent ke, boolean isAltGrDown) { this.keyCode = ke.getKeyCode(); this.isShiftDown = ke.isShiftDown(); this.isControlDown = ke.isControlDown(); this.isAltDown = ke.isAltDown(); this.isAltGrDown = isAltGrDown; this.location = ke.getKeyLocation(); hashCode = keyCode + (isShiftDown ? 1 : 0) + (isControlDown ? 1 : 0) + (isAltDown ? 1 : 0) + (isAltGrDown ? 1 : 0) + location; }
Example 10
Source File: KeyGetter.java From tn5250j with GNU General Public License v2.0 | 6 votes |
void processVTKeyReleased(KeyEvent e){ displayInfo(e); if (isLinux && e.getKeyCode() == KeyEvent.VK_ALT_GRAPH) { isAltGr = false; } int keycode = e.getKeyCode(); if (e.isAltDown() || e.isShiftDown() || e.isControlDown() || e.isActionKey() || keycode == KeyEvent.VK_CONTROL) { keyevent = e; // displayInfo(e,"Released added"); dialog.setVisible(false); dialog.dispose(); } }
Example 11
Source File: ConsoleTextPane.java From energy2d with GNU Lesser General Public License v3.0 | 6 votes |
/** * Custom key event processing for command history implementation. Captures * key up and key down * strokes to call command history and redefines the * same events with control down to allow caret * vertical shift. */ protected void processKeyEvent(KeyEvent e) { // Id Control key is down, captures events does command history recall // and inhibits caret vertical shift. if (e.getKeyCode() == KeyEvent.VK_UP && e.getID() == KeyEvent.KEY_PRESSED && !e.isControlDown()) { recallCommand(true); } else if (e.getKeyCode() == KeyEvent.VK_DOWN && e.getID() == KeyEvent.KEY_PRESSED && !e.isControlDown()) { recallCommand(false); } // If Control key is down, redefines the event as if it where a key up // or key down stroke without // modifiers. This allows to move the caret up and down with no command // history recall. else if ((e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) && e.getID() == KeyEvent.KEY_PRESSED && e.isControlDown()) { super.processKeyEvent(new KeyEvent((Component) e.getSource(), e.getID(), e.getWhen(), 0, // No modifiers e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); } // Standard processing for other events. else { super.processKeyEvent(e); } }
Example 12
Source File: ClipboardKeyAdapter.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
@Override public void keyReleased(KeyEvent event) { if (event.isControlDown() || event.isMetaDown()) { switch (event.getKeyCode()) { case KeyEvent.VK_C: // Copy cancelEditing(); XTableUtils.copyToClipboard(table, false); break; case KeyEvent.VK_X: // Cut cancelEditing(); XTableUtils.copyToClipboard(table, true); break; case KeyEvent.VK_V: // Paste cancelEditing(); XTableUtils.pasteFromClipboard(table); break; default: break; } } }
Example 13
Source File: WTextFieldPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleJavaKeyEvent(KeyEvent e) { switch (e.getID()) { case KeyEvent.KEY_TYPED: if ((e.getKeyChar() == '\n') && !e.isAltDown() && !e.isControlDown()) { postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED, getText(), e.getWhen(), e.getModifiers())); return true; } break; } return false; }
Example 14
Source File: WTextFieldPeer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleJavaKeyEvent(KeyEvent e) { switch (e.getID()) { case KeyEvent.KEY_TYPED: if ((e.getKeyChar() == '\n') && !e.isAltDown() && !e.isControlDown()) { postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED, getText(), e.getWhen(), e.getModifiers())); return true; } break; } return false; }
Example 15
Source File: WTextFieldPeer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleJavaKeyEvent(KeyEvent e) { switch (e.getID()) { case KeyEvent.KEY_TYPED: if ((e.getKeyChar() == '\n') && !e.isAltDown() && !e.isControlDown()) { postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED, getText(), e.getWhen(), e.getModifiers())); return true; } break; } return false; }
Example 16
Source File: KeyStroker.java From tn5250j with GNU General Public License v2.0 | 5 votes |
public boolean equals(KeyEvent ke) { return (keyCode == ke.getKeyCode() && isShiftDown == ke.isShiftDown() && isControlDown == ke.isControlDown() && isAltDown == ke.isAltDown() && isAltGrDown == ke.isAltGraphDown() && location == ke.getKeyLocation()); }
Example 17
Source File: ObjectSelector.java From jaamsim with Apache License 2.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); boolean control = e.isControlDown(); if (control && keyCode == KeyEvent.VK_C) { if (currentEntity != null) { GUIFrame.getInstance().copyToClipboard(currentEntity); } } if (control && keyCode == KeyEvent.VK_V) { GUIFrame.getInstance().pasteEntityFromClipboard(); } }
Example 18
Source File: JConsolePanel.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
@Override public void keyPressed(KeyEvent key) { switch (key.getKeyCode()) { case KeyEvent.VK_C: if (key.isControlDown()) { key.consume(); append("\n"); append(prompt.getPrompt()); setCaretPosition(getText().length()); cp = getCaretPosition(); } break; case KeyEvent.VK_UP: String prev = history.prev(); if (prev != null) { replaceRange(prev, cp, getText().length()); } key.consume(); break; case KeyEvent.VK_DOWN: String next = history.next(); if (next != null) { replaceRange(next, cp, getText().length()); } key.consume(); break; case KeyEvent.VK_LEFT: case KeyEvent.VK_BACK_SPACE: if (cp == getCaretPosition()) { key.consume(); } break; case KeyEvent.VK_ENTER: key.consume(); String t = getText(); append("\n"); if (cmd != null) { String c = t.substring(cp); if (!c.isEmpty()) { append(cmd.handle(c)); history.appendCommand(c); } } append(prompt.getPrompt()); setCaretPosition(getText().length()); cp = getCaretPosition(); } }
Example 19
Source File: Diagrama.java From brModelo with GNU General Public License v3.0 | 4 votes |
/** * Recebe as teclas do Editor. * * @param e */ public void ProcesseTeclas(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { setComando(null); return; } if (e.getKeyCode() == KeyEvent.VK_ENTER) { InspectorItemBase ppr = getEditor().getInspectorEditor().FindByProperty("setTexto"); if (ppr != null) { if (getEditor().getInspectorEditor().getSelecionado() == ppr) { getEditor().getInspectorEditor().PerformSelect(null); } getEditor().getInspectorEditor().PerformSelect(ppr); if (ppr instanceof InspectorItemExtender) { ((InspectorItemExtender) ppr).ExternalRun(); } } return; } if (itensSelecionados.isEmpty()) { return; } FormaElementar item = itensSelecionados.get(0); int x = 0, y = 0; int inc = 3; if (e.isControlDown()) { inc = 1; } switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: x = -inc; y = 0; break; case KeyEvent.VK_RIGHT: x = inc; y = 0; break; case KeyEvent.VK_UP: x = 0; y = -inc; break; case KeyEvent.VK_DOWN: x = 0; y = inc; break; } if (item.isAncorado()) { //HidePontosOnSelecao(false); e.consume(); } else if (x != 0 || y != 0) { if (e.isShiftDown() && item instanceof Forma) { Rectangle rec = new Rectangle(0, 0, -x, -y); ((Forma) item).DoFormaResize(rec); } else { item.DoRaiseMove(x, y); } superAncorador.Posicione(item); DoBaseReenquadreReposicione(); HidePontosOnSelecao(false); PerformInspector(); e.consume(); } }
Example 20
Source File: DefaultKeyboardHandler.java From tn5250j with GNU General Public License v2.0 | 4 votes |
protected void displayInfo(KeyEvent e, String s) { String charString, keyCodeString, modString, tmpString, isString; char c = e.getKeyChar(); int keyCode = e.getKeyCode(); int modifiers = e.getModifiers(); if (Character.isISOControl(c)) { charString = "key character = " + "(an unprintable control character)"; } else { charString = "key character = '" + c + "'"; } keyCodeString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")"; if (keyCode == KeyEvent.VK_PREVIOUS_CANDIDATE) { keyCodeString += " previous candidate "; } if (keyCode == KeyEvent.VK_DEAD_ABOVEDOT || keyCode == KeyEvent.VK_DEAD_ABOVERING || keyCode == KeyEvent.VK_DEAD_ACUTE || keyCode == KeyEvent.VK_DEAD_BREVE || keyCode == KeyEvent.VK_DEAD_CIRCUMFLEX ) { keyCodeString += " dead key "; } modString = "modifiers = " + modifiers; tmpString = KeyEvent.getKeyModifiersText(modifiers); if (tmpString.length() > 0) { modString += " (" + tmpString + ")"; } else { modString += " (no modifiers)"; } isString = "isKeys = isActionKey (" + e.isActionKey() + ")" + " isAltDown (" + e.isAltDown() + ")" + " isAltGraphDown (" + e.isAltGraphDown() + ")" + " isAltGraphDownLinux (" + isAltGr + ")" + " isControlDown (" + e.isControlDown() + ")" + " isMetaDown (" + e.isMetaDown() + ")" + " isShiftDown (" + e.isShiftDown() + ")"; String newline = "\n"; System.out.println(s + newline + " " + charString + newline + " " + keyCodeString + newline + " " + modString + newline + " " + isString + newline); }