List of usage examples for java.awt.event KeyEvent getKeyChar
public char getKeyChar()
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 w w w. ja va 2s . com } // 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();//from ww w.j a v a 2 s . c o m } 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(); } } 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:com.hexidec.ekit.EkitCore.java
public void keyTyped(KeyEvent ke) { // log.debug("> keyTyped(" + ke.getKeyChar() + ")"); Element elem;//ww w. java 2 s .co 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"); // } } }
From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java
private void m_jKeyFactoryKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_m_jKeyFactoryKeyTyped m_jKeyFactory.setText(null);//from ww w . j a va 2 s . com try { stateTransition(evt.getKeyChar()); } catch (BasicException ex) { logger.info("Order No." + m_oTicket.getOrderId() + " exception while calling stateTransition" + ex.getMessage()); Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jDumpPageDirectoryAddressTextFieldKeyTyped(KeyEvent evt) { if (evt.getKeyChar() == '\n') { jDumpPageTableAtAddressButtonActionPerformed(null); }// ww w. j a va 2 s.c o m }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jAddressTextFieldKeyTyped(KeyEvent evt) { if (evt.getKeyChar() == '\n') { jRefreshAddressTranslateButtonActionPerformed(null); }/*from w ww . j ava 2s .c o m*/ }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jTextField1KeyTyped(KeyEvent evt) { if (evt.getKeyChar() == '\n') { jSearchObjdumpButtonActionPerformed(null); }/*from ww w . j a v a 2s. co m*/ }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jTextField2KeyTyped(KeyEvent evt) { if (evt.getKeyChar() == '\n') { jSearchRelPltButtonActionPerformed(null); }/* ww w .j a va 2s . com*/ }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jTextField3KeyTyped(KeyEvent evt) { if (evt.getKeyChar() == '\n') { jSearchDynamicButtonActionPerformed(null); }//from w w w .ja va 2 s .c o m }
From source file:com.peterbochs.PeterBochsDebugger.java
private void bochsCommandTextFieldKeyTyped(KeyEvent evt) { if (evt.getKeyChar() == '\n') { bochsCommandButtonActionPerformed(null); bochsCommandTextField.setText(""); }/*w w w . j a va 2 s.c o m*/ }