List of usage examples for java.awt.event KeyEvent consume
public void consume()
From source file:ecorecyclesimulator.RmosGUI.java
private void validateForInteger(char input, java.awt.event.KeyEvent e) { if (!(Character.isDigit(input)) || (input == KeyEvent.VK_BACK_SPACE) || (input == KeyEvent.VK_DELETE)) { getToolkit().beep();/* ww w .j a va2 s . c om*/ e.consume(); } }
From source file:com.hexidec.ekit.EkitCore.java
public void keyReleased(KeyEvent ke) { // log.debug("> keyReleased"); if (ke.getKeyChar() == KeyEvent.VK_ENTER && (enterIsBreak || inlineEdit)) { ke.consume(); }/*from ww w . j a v a2s . co m*/ // Verifica se est em tabela if (DocumentUtil.getElementByTag(htmlDoc, jtpMain.getCaretPosition(), Tag.TD) != null) { refreshOnUpdate(); } // log.debug("< keyReleased"); }
From source file:com.hexidec.ekit.EkitCore.java
public void keyPressed(KeyEvent ke) { // log.debug("> keyPressed"); int keyCode = ke.getKeyCode(); if (ke.getKeyChar() == KeyEvent.VK_ENTER && (enterIsBreak || inlineEdit)) { ke.consume(); } else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_KP_UP) { Element tdElement = DocumentUtil.getElementByTag(htmlDoc, jtpMain.getCaretPosition(), Tag.TD); if (tdElement != null) { moveCaretOnTable(tdElement, true, ke.isShiftDown()); ke.consume();//w w w . j a v a 2s . c o m } } else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_KP_DOWN) { Element tdElement = DocumentUtil.getElementByTag(htmlDoc, jtpMain.getCaretPosition(), Tag.TD); if (tdElement != null) { moveCaretOnTable(tdElement, false, ke.isShiftDown()); ke.consume(); } } else if (keyCode == KeyEvent.VK_ENTER) { Element tdElement = DocumentUtil.getElementByTag(htmlDoc, jtpMain.getCaretPosition(), Tag.TD); // inside table if (tdElement != null) { try { insertBreakInsideTD(tdElement); } catch (Exception e) { log.error("Falha ao inserir quebra de linha.", e); } ke.consume(); } } else if (keyCode == KeyEvent.VK_D && ke.isShiftDown() && ke.isControlDown()) { debug(); } // log.debug("< keyPressed"); }
From source file:uk.ac.kcl.texthunter.core.AnnotationEditor.java
private void keyObsEditorPaneKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_keyObsEditorPaneKeyTyped if (useNumericKeysCheckBox.isSelected()) { evt.consume(); }//from w ww. j a v a 2s .c om }
From source file:uk.ac.kcl.texthunter.core.AnnotationEditor.java
private void keyObsEditorPaneKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_keyObsEditorPaneKeyReleased if (useNumericKeysCheckBox.isSelected()) { evt.consume(); }/*from w w w. j av a2s . c o m*/ }
From source file:com.osparking.osparking.Settings_System.java
private void lotNameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lotNameTextFieldKeyTyped if (lotNameTextField.getText().trim().length() >= PARKING_LOT_NAME_LENGTH_MAX) { getToolkit().beep();//from w w w .j ava 2 s. c om JOptionPane.showConfirmDialog(this, LOT_NAME_LABEL.getContent() + " " + LIMIT_LABEL.getContent() + " : " + PARKING_LOT_NAME_LENGTH_MAX, ERROR_DIALOGTITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE); evt.consume(); } }
From source file:com.osparking.osparking.Settings_System.java
private void rejectLongPortNumber(KeyEvent evt, DeviceType devType, int gateNo) { JTextField portField = (JTextField) componentMap.get(devType.toString() + gateNo + "_Port_TextField"); if (portField.getText().trim().length() >= PORT_NUMBER_LENGTH_MAX) { getToolkit().beep();//from w w w.j a v a 2 s. com JOptionPane.showConfirmDialog(this, PORT_LABEL.getContent() + " " + NUMBER_LIMIT_DESCRIPTION.getContent() + " : " + PORT_NUMBER_LENGTH_MAX, ERROR_DIALOGTITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE); evt.consume(); } else { // check if portField input is in the available range of port number. } }
From source file:com.osparking.osparking.Settings_System.java
private void checkGateNameLength(int gateNo, KeyEvent evt) { JTextField gateNameField = (JTextField) getComponentByName("TextFieldGateName" + gateNo); String gateName = gateNameField.getText().trim(); if (gateName.length() > GATE_NAME_LENGTH_MAX) { gateNameField.setText(gateNames[gateNo]); getToolkit().beep();//from w w w. j a v a 2 s. co m JOptionPane.showConfirmDialog(this, GATE_NAME_LABEL2.getContent() + " " + System.lineSeparator() + System.lineSeparator() + LIMIT_LABEL.getContent() + GATE_NAME_LENGTH_MAX, ERROR_DIALOGTITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE); evt.consume(); } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
public void keyPressed(KeyEvent e) { logDebug("keyPressed"); int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_TAB || key == KeyEvent.VK_DOWN || key == KeyEvent.VK_UP || (key == KeyEvent.VK_TAB && e.isShiftDown()) || key == KeyEvent.VK_HOME || key == KeyEvent.VK_END) { editInvalidCell(e);/* www. j ava 2 s . com*/ e.consume(); } }
From source file:com.hexidec.ekit.EkitCore.java
public void keyTyped(KeyEvent ke) { // log.debug("> keyTyped(" + ke.getKeyChar() + ")"); Element elem;// w w w. j ava 2s .c o m int pos = this.getCaretPosition(); int repos = -1; if (ke.getKeyChar() == KeyEvent.VK_BACK_SPACE) { try { if (pos > 0) { // if (jtpMain.getSelectedText() != null) { // htmlUtilities.delete(); // refreshOnUpdate(); // return; // } else { int sOffset = htmlDoc.getParagraphElement(pos).getStartOffset(); if (sOffset == jtpMain.getSelectionStart()) { boolean content = true; if (htmlUtilities.checkParentsTag(HTML.Tag.LI)) { elem = htmlUtilities.getListItemParent(); content = false; int so = elem.getStartOffset(); int eo = elem.getEndOffset(); if (so + 1 < eo) { char[] temp = jtpMain.getText(so, eo - so).toCharArray(); for (char c : temp) { if (!(new Character(c)).isWhitespace(c)) { content = true; } } } if (!content) { htmlUtilities.removeTag(elem, true); this.setCaretPosition(sOffset - 1); refreshOnUpdate(); return; } else { jtpMain.replaceSelection(""); refreshOnUpdate(); return; } } else if (htmlUtilities.checkParentsTag(HTML.Tag.TABLE)) { jtpMain.setCaretPosition(jtpMain.getCaretPosition() - 1); ke.consume(); refreshOnUpdate(); return; } } jtpMain.replaceSelection(""); refreshOnUpdate(); return; // } } } catch (BadLocationException ble) { logException("BadLocationException in keyTyped method", ble); new SimpleInfoDialog(this.getWindow(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR); } // catch (IOException ioe) { // logException("IOException in keyTyped method", ioe); // new SimpleInfoDialog(this.getWindow(), // Translatrix.getTranslationString("Error"), true, // Translatrix.getTranslationString("ErrorIOException"), // SimpleInfoDialog.ERROR); // } // finally { // log.debug("< keyTyped"); // } } else if (ke.getKeyChar() == KeyEvent.VK_ENTER && !inlineEdit) { try { if (htmlUtilities.checkParentsTag(HTML.Tag.UL) == true | htmlUtilities.checkParentsTag(HTML.Tag.OL) == true) { elem = htmlUtilities.getListItemParent(); int so = elem.getStartOffset(); int eo = elem.getEndOffset(); char[] temp = this.getTextPane().getText(so, eo - so).toCharArray(); boolean content = false; for (char c : temp) { if (!(new Character(c)).isWhitespace(c)) { content = true; } } if (content) { int end = -1; int j = temp.length; do { j--; if (new Character(temp[j]).isLetterOrDigit(temp[j])) { end = j; } } while (end == -1 && j >= 0); j = end; do { j++; if (!new Character(temp[j]).isSpaceChar(temp[j])) { repos = j - end - 1; } } while (repos == -1 && j < temp.length); if (repos == -1) { repos = 0; } } if (!content) { removeEmptyListElement(elem); } else { if (this.getCaretPosition() + 1 == elem.getEndOffset()) { insertListStyle(elem); this.setCaretPosition(pos - repos); } else { int caret = this.getCaretPosition(); String tempString = this.getTextPane().getText(caret, eo - caret); if (tempString != null && tempString.length() > 0) { this.getTextPane().select(caret, eo - 1); this.getTextPane().replaceSelection(""); htmlUtilities.insertListElement(tempString); Element newLi = htmlUtilities.getListItemParent(); this.setCaretPosition(newLi.getEndOffset() - 1); } } } } else if (enterIsBreak) { insertBreak(); ke.consume(); } } catch (BadLocationException ble) { logException("BadLocationException in keyTyped method", ble); new SimpleInfoDialog(this.getWindow(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR); } catch (IOException ioe) { logException("IOException in keyTyped method", ioe); new SimpleInfoDialog(this.getWindow(), Translatrix.getTranslationString("Error"), true, Translatrix.getTranslationString("ErrorIOException"), SimpleInfoDialog.ERROR); } // finally { // log.debug("< keyTyped"); // } } }