List of usage examples for java.awt.event KeyEvent VK_BACK_SPACE
int VK_BACK_SPACE
To view the source code for java.awt.event KeyEvent VK_BACK_SPACE.
Click Source Link
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);/*from w w w . j a v a 2s . 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:vistas.GestionPersonal.java
private void txt_NameKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_NameKeyTyped char car = evt.getKeyChar(); if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE) && (car != (char) KeyEvent.VK_BACK_SPACE)) { JOptionPane.showMessageDialog(this, "Ingrese solo letras"); evt.consume();//from w w w . j av a 2 s . com } }
From source file:vistas.GestionPersonal.java
private void txt_apellidoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_apellidoKeyTyped char car = evt.getKeyChar(); if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z') && (car != (char) KeyEvent.VK_SPACE) && (car != (char) KeyEvent.VK_BACK_SPACE)) { JOptionPane.showMessageDialog(this, "Ingrese solo letras"); evt.consume();/* w ww . j a v a2s . com*/ } }
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 a v a 2s .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; } }); } }
From source file:vistas.GestionPersonal.java
private void txt_horaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_horaKeyTyped char car = evt.getKeyChar(); if (txt_hora.getText().length() >= 8) { JOptionPane.showMessageDialog(this, "Permitido hasta 8 digitos"); evt.consume();//from w w w . j a v a2 s. c o m } if ((car < '0' || car > '9') && (car != (char) KeyEvent.VK_BACK_SPACE)) { JOptionPane.showMessageDialog(this, "Solo numeros"); evt.consume(); } }
From source file:plugin.notes.gui.NotesView.java
private void editorKeyTyped(KeyEvent evt) { editor.getCaretPosition();// ww w . j av a 2s. c om editor.getStyledDocument(); if (evt.getKeyChar() == KeyEvent.VK_BACK_SPACE) { handleBackspace(); } else if (evt.getKeyChar() == KeyEvent.VK_ENTER) { handleEnter(); } }
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 . java 2 s . c o m*/ // 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 w w .jav a2s . c om // 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:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
private void formKeyReleased(KeyEvent evt) { switch (evt.getKeyCode()) { case CAMERA_UP_KEY: cameraUpKeyPressed = false;/*from w w w. j av a2s . com*/ processCameraKeys(evt); break; case CAMERA_DOWN_KEY: cameraDownKeyPressed = false; processCameraKeys(evt); break; case CAMERA_LEFT_KEY: cameraLeftKeyPressed = false; processCameraKeys(evt); break; case CAMERA_RIGHT_KEY: cameraRightKeyPressed = false; processCameraKeys(evt); break; case CAMERA_FORWARD_KEY: cameraForwardKeyPressed = false; processCameraKeys(evt); break; case CAMERA_BACKWARD_KEY: cameraBackwardKeyPressed = false; processCameraKeys(evt); break; case KeyEvent.VK_BACK_SPACE: reset(); break; default: break; } }
From source file:tax.MainForm.java
private void dateTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dateTextKeyReleased int keyCode = evt.getKeyCode(); if ((keyCode == KeyEvent.VK_BACK_SPACE) || (keyCode == KeyEvent.VK_DELETE)) { lastDateTextLength = dateText.getText().length(); }/*from w ww . ja v a 2 s . c o m*/ }