List of usage examples for java.awt.event KeyEvent isControlDown
public boolean isControlDown()
From source file:Main.java
private void displayInfo(KeyEvent e, String keyStatus) { // You should only rely on the key char if the event // is a key typed event. int id = e.getID(); String keyString;//from w ww . jav a 2 s. c om if (id == KeyEvent.KEY_TYPED) { char c = e.getKeyChar(); keyString = "key character = '" + c + "'"; } else { int keyCode = e.getKeyCode(); keyString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")"; } int modifiersEx = e.getModifiersEx(); String modString = "extended modifiers = " + modifiersEx; String tmpString = KeyEvent.getModifiersExText(modifiersEx); System.out.println(e.isControlDown()); if (tmpString.length() > 0) { modString += " (" + tmpString + ")"; } else { modString += " (no extended modifiers)"; } String actionString = "action key? "; if (e.isActionKey()) { actionString += "YES"; } else { actionString += "NO"; } String locationString = "key location: "; int location = e.getKeyLocation(); if (location == KeyEvent.KEY_LOCATION_STANDARD) { locationString += "standard"; } else if (location == KeyEvent.KEY_LOCATION_LEFT) { locationString += "left"; } else if (location == KeyEvent.KEY_LOCATION_RIGHT) { locationString += "right"; } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) { locationString += "numpad"; } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN) locationString += "unknown"; } displayArea.append(keyStatus + newline + " " + keyString + newline + " " + modString + newline + " " + actionString + newline + " " + locationString + newline); displayArea.setCaretPosition(displayArea.getDocument().getLength()); }
From source file:net.sf.maltcms.chromaui.chromatogram2Dviewer.ui.panel.Chromatogram2DViewerPanel.java
@Override public void keyPressed(KeyEvent ke) { Logger.getLogger(getClass().getName()).log(Level.INFO, "Received key event: {0}", ke.toString()); if (ke.isControlDown()) { modeSpinner.setValue(InstanceContentSelectionHandler.Mode.ON_HOVER.toString()); }//from w ww . j a v a 2s . co m // if (getDataPoint() != null) { // Logger.getLogger(getClass().getName()).info("Data point is not null!"); // Point p = null; // if (ke.getKeyCode() == KeyEvent.VK_RIGHT) { // p = new Point(getDataPoint()); // p.translate(1, 0); // } else if (ke.getKeyCode() == KeyEvent.VK_LEFT) { // p = new Point(getDataPoint()); // p.translate(-1, 0); // } else if (ke.getKeyCode() == KeyEvent.VK_UP) { // p = new Point(getDataPoint()); // p.translate(0, 1); // } else if (ke.getKeyCode() == KeyEvent.VK_DOWN) { // p = new Point(getDataPoint()); // p.translate(0, -1); // } // setDataPoint(p); // if (!ke.isShiftDown()) { //// triggerMSUpdate(); // } // } }
From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.panel.Chromatogram1DHeatmapViewerPanel.java
@Override public void keyPressed(KeyEvent ke) { Logger.getLogger(getClass().getName()).log(Level.INFO, "Received key event: {0}", ke.toString()); if (ke.isControlDown()) { modeSpinner.setValue(InstanceContentSelectionHandler.Mode.ON_HOVER.toString()); }//from w w w.ja va 2s . co m if (getDataPoint() != null) { Logger.getLogger(getClass().getName()).info("Data point is not null!"); Point p = null; if (ke.getKeyCode() == KeyEvent.VK_RIGHT) { p = new Point(getDataPoint()); p.translate(1, 0); } else if (ke.getKeyCode() == KeyEvent.VK_LEFT) { p = new Point(getDataPoint()); p.translate(-1, 0); } else if (ke.getKeyCode() == KeyEvent.VK_UP) { p = new Point(getDataPoint()); p.translate(0, 1); } else if (ke.getKeyCode() == KeyEvent.VK_DOWN) { p = new Point(getDataPoint()); p.translate(0, -1); } setDataPoint(p); if (!ke.isShiftDown()) { // triggerMSUpdate(); } } }
From source file:Console.java
public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) { if (outputMark == getCaretPosition()) { e.consume();//from w ww. ja v a2s . c om } } else if (code == KeyEvent.VK_HOME) { int caretPos = getCaretPosition(); if (caretPos == outputMark) { e.consume(); } else if (caretPos > outputMark) { if (!e.isControlDown()) { if (e.isShiftDown()) { moveCaretPosition(outputMark); } else { setCaretPosition(outputMark); } e.consume(); } } } else if (code == KeyEvent.VK_ENTER) { returnPressed(); e.consume(); } else if (code == KeyEvent.VK_UP) { historyIndex--; if (historyIndex >= 0) { if (historyIndex >= history.size()) { historyIndex = history.size() - 1; } if (historyIndex >= 0) { String str = history.elementAt(historyIndex); int len = getDocument().getLength(); replaceRange(str, outputMark, len); int caretPos = outputMark + str.length(); select(caretPos, caretPos); } else { historyIndex++; } } else { historyIndex++; } e.consume(); } else if (code == KeyEvent.VK_DOWN) { int caretPos = outputMark; if (history.size() > 0) { historyIndex++; if (historyIndex < 0) { historyIndex = 0; } int len = getDocument().getLength(); if (historyIndex < history.size()) { String str = history.elementAt(historyIndex); replaceRange(str, outputMark, len); caretPos = outputMark + str.length(); } else { historyIndex = history.size(); replaceRange("", outputMark, len); } } select(caretPos, caretPos); e.consume(); } }
From source file:ucar.unidata.idv.control.chart.ChartHolder.java
/** * Handle event/* www . j a va 2s .co m*/ * * @param e The event */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { panPlot(true); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { panPlot(false); } else if (e.getKeyCode() == KeyEvent.VK_UP) { upDownPlot(true); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { upDownPlot(false); } else if ((e.getKeyCode() == KeyEvent.VK_R) && e.isControlDown()) { chartPanel.restoreAutoBounds(); } else { // super.keyPressed(e); } }
From source file:ucar.unidata.idv.control.chart.PlotWrapper.java
/** * Handle event/*from www . ja v a 2s . c om*/ * * @param e The event */ public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { panPlot(true); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { panPlot(false); } else if (e.getKeyCode() == KeyEvent.VK_UP) { upDownPlot(true); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { upDownPlot(false); } else if ((e.getKeyCode() == KeyEvent.VK_R) && e.isControlDown()) { resetPlot(); } else { super.keyPressed(e); } }
From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java
private void initKeyListener() { //key listener thumbnailList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_UP)) { moveUpButton.doClick();//from w w w.j a va 2s.c o m } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_DOWN)) { moveDownButton.doClick(); } else if ((e.getKeyCode() == KeyEvent.VK_DELETE)) { removeButton.doClick(); } else if (drawDeletedItems && (e.isControlDown()) && (e.getKeyCode() == KeyEvent.VK_Z)) { undeleteButton.doClick(); } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_RIGHT)) { rotateButton.doClick(); } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_LEFT)) { rotateAntiButton.doClick(); } } }); }
From source file:view.MainWindow.java
@Override public boolean dispatchKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { if (e.isControlDown()) { if (e.getKeyCode() == KeyEvent.VK_W) { closeDocument(true);//from w w w .j ava 2s . c o m } else if (e.getKeyCode() == KeyEvent.VK_ADD) { workspacePanel.zoomIn(); } else if (e.getKeyCode() == KeyEvent.VK_SUBTRACT) { workspacePanel.zoomOut(); } else if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_RIGHT) { workspacePanel.pageUp(); } else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_LEFT) { workspacePanel.pageDown(); } if (e.isShiftDown()) { if (e.getKeyCode() == KeyEvent.VK_S) { workspacePanel.changeCard(WorkspacePanel.CardEnum.SIGN_PANEL, true); } else if (e.getKeyCode() == KeyEvent.VK_V) { workspacePanel.changeCard(WorkspacePanel.CardEnum.VALIDATE_PANEL, true); } } } } else if (e.getID() == KeyEvent.KEY_RELEASED) { } else if (e.getID() == KeyEvent.KEY_TYPED) { } return false; }
From source file:br.com.atmatech.sac.view.ViewListaAtendimento.java
private void jTatendimentoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTatendimentoKeyPressed // TODO add your handling code here: if (jTatendimento.getSelectedColumn() >= 0) { coluna = jTatendimento.getSelectedColumn(); } else {//from ww w. j a v a 2s. c o m coluna = 1; } if ((evt.getKeyCode() == KeyEvent.VK_F) && (coluna >= 0) && (!jTatendimento.getColumnName(coluna).equals("DATA"))) { if (evt.isControlDown()) { jLcampo.setText(jTatendimento.getColumnName(coluna)); jTparametro1.setText(""); jCcondicao.setSelectedIndex(4); jDconsulta.setLocationRelativeTo(this); jDconsulta.setVisible(true); // } } }
From source file:tax.MainForm.java
private void priceTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_priceTextKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (!priceText.getText().equals("")) { Util.fadeInAndOut(priceText, Util.darkGreen); afmText.setEnabled(true);/* w w w .j ava2s .c o m*/ afmText.requestFocus(); } else Util.fadeInAndOut(priceText, Util.darkOrange); } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown() && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { String text = priceText.getText(); int priceLength = text.length(); while (lastPriceTextLength == priceLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastPriceTextLength + " " + priceLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = priceText.getText(); priceLength = text.length(); } // if (text.charAt(priceLength - 1) == '\u002c') // priceText.setText(text.substring(0, priceLength - 1) + "."); try { Double.parseDouble(text); } catch (Exception e) { if (text.length() > 0) { // System.out.println(text.charAt(priceLength - 1)); priceText.setText(text.substring(0, priceLength - 1)); } else priceText.setText(""); return; } lastPriceTextLength = priceLength; } }); } }