List of usage examples for java.awt.event KeyEvent isShiftDown
public boolean isShiftDown()
From source file:org.executequery.gui.editor.QueryEditorTextPane.java
/** * Overrides <code>processKeyEvent</code> to additional process events. *//*from w w w .j a va 2s . com*/ protected void processKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { int keyCode = e.getKeyCode(); // add the processing for SHIFT-TAB if (e.isShiftDown() && keyCode == KeyEvent.VK_TAB) { // int currentPosition = getCurrentPosition(); int selectionStart = getSelectionStart(); int selectionEnd = getSelectionEnd(); if (selectionStart == selectionEnd) { int start = getCurrentRowStart(); int end = getCurrentRowEnd(); shiftTextLeft(start, end); /* int newPosition = currentPosition - QueryEditorSettings.getTabSize(); int currentRowPosition = getCurrentRowStart(); if (!isAtStartOfRow()) { if (newPosition < 0) { setCaretPosition(0); } else if (newPosition < currentRowPosition) { setCaretPosition(currentRowPosition); } else { setCaretPosition(newPosition); } } */ } else { document.shiftTabEvent(selectionStart, selectionEnd); } } else if (keyCode == KeyEvent.VK_INSERT && e.getModifiers() == 0) { // toggle insert mode on the document int insertMode = document.getInsertMode(); if (insertMode == SqlMessages.INSERT_MODE) { document.setInsertMode(SqlMessages.OVERWRITE_MODE); editorPanel.getStatusBar().setInsertionMode("OVR"); } else { document.setInsertMode(SqlMessages.INSERT_MODE); editorPanel.getStatusBar().setInsertionMode("INS"); } ((EditorCaret) getCaret()).modeChanged(); } else if (keyCode == KeyEvent.VK_SPACE) { checkForShortcutText(); } } super.processKeyEvent(e); updateLineBorder(); }
From source file:org.slage.ui.KeyHandler.java
/** * Check if the handler should be fired, firing if needed * //from w ww. j ava 2s . co m * @param keyEvt * key event * @return true if we fired */ public boolean fire(KeyEvent keyEvt) { if ((iKey == keyEvt.getKeyCode() || iKey == keyEvt.getKeyChar()) && bAlt == keyEvt.isAltDown() && bCtrl == keyEvt.isControlDown() && bShift == keyEvt.isShiftDown()) { handler.execute(); return true; } return false; }
From source file:tax.MainForm.java
private void dateTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dateTextKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (!dateText.getText().equals("")) { Util.fadeInAndOut(dateText, Util.darkGreen); priceText.setEnabled(true);//w ww. j a v a 2 s.c o m priceText.requestFocus(); } else Util.fadeInAndOut(dateText, 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 = dateText.getText(); int dateLength = text.length(); while (lastDateTextLength == dateLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastDateTextLength + " " + dateLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = dateText.getText(); dateLength = text.length(); } try { int num = Integer.decode(text); if (num > 31) { if (text.length() > 0) dateText.setText(text.substring(0, dateLength - 1)); else dateText.setText(""); return; } } catch (Exception e) { if (text.length() > 0) dateText.setText(text.substring(0, dateLength - 1)); else dateText.setText(""); return; } lastDateTextLength = dateLength; } }); } }
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);//from ww w. j ava 2s .c om 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; } }); } }
From source file:tax.MainForm.java
private void afmTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextKeyPressed String text = afmText.getText(); if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (text.length() == 9) { for (Object key : afmToName.keySet()) { if (afmToName.get(key).equals(text)) nameText.setText(key.toString()); }/*from w ww. j a va 2s. c om*/ // Util.fadeInAndOut(afmText, Util.darkGreen); addRowBut.doClick(); } else if (text.length() == 0) { Util.fadeInAndOut(afmText, Color.white); nameText.setEnabled(true); nameText.requestFocus(); } else Util.fadeInAndOut(afmText, 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 = afmText.getText(); int afmLength = text.length(); while (lastAFMTextLength == afmLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastAFMTextLength + " " + afmLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = afmText.getText(); afmLength = text.length(); } try { int num = Integer.decode(text); if (afmLength > 9) { if (text.length() > 0) afmText.setText(text.substring(0, afmLength - 1)); else afmText.setText(""); return; } } catch (Exception e) { if (text.length() > 0) afmText.setText(text.substring(0, afmLength - 1)); else afmText.setText(""); return; } lastAFMTextLength = afmLength; } }); } }
From source file:tax.MainForm.java
private void afmTextSKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextSKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { String text = afmTextS.getText(); if (text.length() == 9) { try { int num = Integer.parseInt(text); } catch (Exception e) { afmTextS.setText(""); return; }/*from w ww . j a va2s . com*/ // Util.fadeInAndOut(afmTextS, Util.darkGreen); addNameBut.doClick(); } else { Util.fadeInAndOut(afmTextS, 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 = afmTextS.getText(); int afmLength = text.length(); while (lastAFMTextSLength == afmLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastAFMTextSLength + " " + afmLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = afmTextS.getText(); afmLength = text.length(); } try { int num = Integer.decode(text); if (afmLength > 9) { if (text.length() > 0) afmTextS.setText(text.substring(0, afmLength - 1)); else afmTextS.setText(""); return; } } catch (Exception e) { if (text.length() > 0) afmTextS.setText(text.substring(0, afmLength - 1)); else afmTextS.setText(""); return; } lastAFMTextSLength = afmLength; } }); } }
From source file:tufts.vue.RichTextBox.java
private static boolean isFinishEditKeyPress(KeyEvent e) { // if we hit return key either on numpad ("enter" key), or // with any modifier down except a shift alone (in case of // caps lock) complete the edit. return e.getKeyCode() == KeyEvent.VK_ENTER && (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD || (e.getModifiersEx() != 0 && !e.isShiftDown())) == true; //== false; // reversed logic of below description }
From source file:tufts.vue.RichTextBox.java
public void keyPressed(KeyEvent e) { if (DEBUG.KEYS) out(e.toString());/* www . j a v a 2s . c om*/ //System.out.println("TextBox: " + e); //if (VueUtil.isAbortKey(e)) // check for ESCAPE for CTRL-Z or OPTION-Z if on mac if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { e.consume(); // System.out.println(mUnchangedText); //setText(mUnchangedText); revert = true; getParent().remove(this); // will trigger a save (via focusLost) return; // setSize(mUnchangedSize); // todo: won't be good enough if we ever resize the actual node as we type } else if (isFinishEditKeyPress(e)) { keyWasPressed = true; e.consume(); getParent().remove(this); // will trigger a save (via focusLost) VUE.getFormattingPanel().getTextPropsPane().getFontEditorPanel().updateFormatControlsTB(this); } else if (e.getKeyCode() == KeyEvent.VK_U && e.isMetaDown()) { e.consume(); String t = getText(); if (e.isShiftDown()) setText(t.toUpperCase()); // upper whole string else setText(Character.toTitleCase(t.charAt(0)) + t.substring(1)); // upper first char } else keyWasPressed = true; // Dimension d = preAddDimension; // d.height = this.getPreferredSize().height; // setSize(getPreferredSize()); // action keys will be ignored if we consume this here! // (e.g., "enter" does nothing) //e.consume(); }
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);//w w w .ja v a2 s.com } 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; }