Exemple #1
0
 protected void processKeyEvent(final KeyEvent e) {
   int id = e.getID();
   switch (id) {
     case KeyEvent.KEY_TYPED:
       KeyEventCZ loKey = new KeyEventCZ(e.getKeyChar());
       moTipo.getTecla(super.getText(), loKey);
       e.setKeyChar(loKey.getKeyChar());
       break;
     case KeyEvent.KEY_PRESSED:
       if (e.getKeyCode() == e.VK_ENTER) {
         e.setKeyCode(0);
         transferFocus();
       }
       if (e.getKeyCode() == e.VK_ESCAPE) {
         e.setKeyCode(0);
         moTipo.restaurarTexto();
         super.setText(moTipo.getText());
       }
       break;
     case KeyEvent.KEY_RELEASED:
       break;
     default:
   }
   super.processKeyEvent(e);
 }
 private void jTextArea1KeyTyped(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jTextArea1KeyTyped
   // TODO add your handling code here:
   if (jTextArea1.getText().length() >= 300) {
     char temp = 0;
     evt.setKeyChar(temp);
   }
 } // GEN-LAST:event_jTextArea1KeyTyped
 private void jTextField1KeyTyped(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jTextField1KeyTyped
   // TODO add your handling code here:
   if (jTextField1.getText().length() >= 40) {
     char temp = 0;
     evt.setKeyChar(temp);
   }
   char caracter = evt.getKeyChar();
   if (!((caracter >= 'A' && caracter <= 'Z')
       || caracter == 8
       || caracter == ':'
       || caracter == '"'
       || (caracter >= 'a' && caracter <= 'z'))) {
     char temp = 0;
     evt.setKeyChar(temp);
   } //
 } // GEN-LAST:event_jTextField1KeyTyped
 private void jTextField5KeyTyped(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jTextField5KeyTyped
   // TODO add your handling code here:
   char caracter = evt.getKeyChar();
   if (!((caracter >= '0' && caracter <= '9') || caracter == 8)) {
     char temp = 0;
     evt.setKeyChar(temp);
   }
 } // GEN-LAST:event_jTextField5KeyTyped
 private void CTciudadKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_CTciudadKeyTyped
   int k = (int) evt.getKeyChar();
   if (k > 47 && k < 58) {
     evt.setKeyChar((char) KeyEvent.VK_CLEAR);
     JOptionPane.showMessageDialog(
         null, "No puede ingresar numeros!!!", "Ventana Error Datos", JOptionPane.ERROR_MESSAGE);
   }
   if (k == 10) {
     CTciudad.transferFocus();
   }
 } // GEN-LAST:event_CTciudadKeyTyped
Exemple #6
0
 /**
  * @autor Misayo Metodo que permite presionar y convertir letras en mayusculas; no se permite
  *     presionar la tecla apostrofe
  * @param java.awt.event.KeyEvent evt evento de la tecla presionada
  */
 public static void presionarCaracteresEspacioMayusculas(java.awt.event.KeyEvent evt) {
   char key = evt.getKeyChar();
   if (key >= 'a' && key <= 'z'
       || (key == 'á' || key == 'é' || key == 'í' || key == 'ó' || key == 'ú'))
     evt.setKeyChar((char) (((int) evt.getKeyChar()) - 32));
   else if ((key == comillaSimple)
       && (key < 'A' || key > 'Z')
       && (key != 'Ñ')
       && (key != 'Á')
       && (key != 'É')
       && (key != 'Í')
       && (key != 'Ó')
       && (key != 'Ú')) evt.consume();
 }
Exemple #7
0
 /**
  * @autor Jack Krauser Metodo que permite presionar y convertir letras en mayusculas y numeros; no
  *     se permiten presionar la tecla espacio y apostrofe
  * @param java.awt.event.KeyEvent evt evento de la tecla presionada
  */
 public static void presionarAlfanumericoMayusculas(java.awt.event.KeyEvent evt) {
   char key = evt.getKeyChar();
   if (key >= 'a' && key <= 'z'
       || (key == 'ñ')
       || (key == 'á' || key == 'é' || key == 'í' || key == 'ó' || key == 'ú'))
     evt.setKeyChar((char) (((int) evt.getKeyChar()) - 32));
   else if ((key < '0' || key > '9')
       && (key != underscore && key != minus && key != arroba && key != slash && key != asterisco)
       && (key < 'A' || key > 'Z')
       && (key != 'Ñ')
       && (key != 'Á')
       && (key != 'É')
       && (key != 'Í')
       && (key != 'Ó')
       && (key != 'Ú')) evt.consume();
 }
Exemple #8
0
 /**
  * @autor Jack Krauser Metodo que permite presionar y convertir letras en mayusculas y la tecla
  *     espacio sin permitir la letra Ñ
  * @param java.awt.event.KeyEvent evt evento de la tecla presionada
  */
 public static void presionarLetrasMayusculasEspacioSinEnie(java.awt.event.KeyEvent evt) {
   char key = evt.getKeyChar();
   if ((key >= 'a' && key <= 'z')
       || // (key != 'ñ') ||
       (key == 'á' || key == 'é' || key == 'í' || key == 'ó' || key == 'ú'))
     evt.setKeyChar((char) (((int) evt.getKeyChar()) - 32));
   else if ((key != KeyEvent.VK_SPACE)
       && (key > '0' || key < '9')
       && (key < 'A' || key > 'Z')
       && (key != 'Ñ')
       && (key != 'Á')
       && (key != 'É')
       && (key != 'Í')
       && (key != 'Ó')
       && (key != 'Ú')) evt.consume();
 }
Exemple #9
0
 @Override
 protected void processKeyEvent(KeyEvent e) {
   char c = e.getKeyChar();
   c = Character.toUpperCase(c);
   e.setKeyChar(c);
   int cd = e.getKeyCode();
   if ((c == KeyEvent.VK_DELETE) || (c == KeyEvent.VK_ENTER)) {
     super.processKeyEvent(e);
     return;
   }
   if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_ESCAPE)) {
     super.processKeyEvent(e);
     return;
   }
   if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'))) {
     if (getCaretPosition() > 0) super.processKeyEvent(e);
     return;
   }
 }
Exemple #10
0
  public void keyTyped(KeyEvent e) {
    char code = e.getKeyChar();
    if (code == e.VK_ENTER) {
      //      if (dataField != null)
      {
        e.setKeyChar(e.CHAR_UNDEFINED);
        e.setKeyCode(-1);

        // only fire this event, if the data has been changed
        if (textField.isDataChanged()) {
          fireActionPerformed("enter");
        }

        // not shift + enter => focus to next
        if ((e.getModifiers() & e.SHIFT_MASK) != e.SHIFT_MASK) {
          this.changeFocusToNext();
        }
      }
    } else {
      if (!TKeyLock.keys.isLocked()) {
        textField.setDataChanged(true);
      }
    }
  }