Example usage for java.awt.event KeyEvent getKeyChar

List of usage examples for java.awt.event KeyEvent getKeyChar

Introduction

In this page you can find the example usage for java.awt.event KeyEvent getKeyChar.

Prototype

public char getKeyChar() 

Source Link

Document

Returns the character associated with the key in this event.

Usage

From source file:controlador.ControladorReportes.java

@Override
public void keyTyped(KeyEvent e) {
    System.out.println(e.getKeyChar());
    if (!Character.isDigit(e.getKeyChar())) {
        System.out.println(e.getKeyChar());
        e.consume();//from www  .j ava  2 s.  c  om
    }
}

From source file:vistas.ModPersonal.java

private void txt_NameMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_NameMKeyTyped
    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  va 2  s  .c  om*/
    }
}

From source file:vistas.ModPersonal.java

private void txt_DniMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_DniMKeyTyped
    char car = evt.getKeyChar();
    if (txt_DniM.getText().length() >= 9) {
        JOptionPane.showMessageDialog(this, "Permitido hasta 8 digitos");
        evt.consume();/*from   w w  w .  ja  v a 2 s .  co m*/
    }
    if ((car < '0' || car > '9')) {
        JOptionPane.showMessageDialog(this, "Solo numeros");
        evt.consume();
    }
}

From source file:vistas.ModPersonal.java

private void txt_apellidoMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_apellidoMKeyTyped
    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  w w . j  a v  a  2  s . com*/
    }
}

From source file:vistas.ModPersonal.java

private void txt_horaMKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_horaMKeyTyped
    char car = evt.getKeyChar();
    if (txt_horaM.getText().length() >= 8) {
        JOptionPane.showMessageDialog(this, "Permitido hasta 8 digitos");
        evt.consume();/*from  www . ja  va  2  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:PruebaMixto.java

private void txt_gKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_gKeyTyped

    char a = evt.getKeyChar();
    if (a < '0' || a > '9') {
        evt.consume();/*w  w w  .  j  a v  a2s .co m*/
    } // TODO add your handling code here:
}

From source file:PruebaMixto.java

private void txt_kKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_kKeyTyped

    char a = evt.getKeyChar();
    if (a < '0' || a > '9') {
        evt.consume();//ww  w. ja v  a 2 s.co m
    } // TODO add your handling code here:
}

From source file:com.cmsoftware.keyron.vista.admin.ActivarEmpleado.java

private void claveKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_claveKeyTyped
    clave.setBackground(new Color(255, 255, 255));
    if (KeyEvent.VK_ENTER == evt.getKeyChar()) {
        activarEmpleado();/*from   www . j a va  2s.c  o  m*/
    } else {
        labelError.setText("");
    }
}

From source file:com.cmsoftware.keyron.vista.admin.ActivarEmpleado.java

private void correoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_correoKeyTyped
    correo.setBackground(new Color(255, 255, 255));
    if (KeyEvent.VK_ENTER == evt.getKeyChar()) {
        activarEmpleado();//w w w .j  ava  2  s . c  o  m
    } else {
        labelError.setText("");
    }
}

From source file:interfazGrafica.frmMoverRFC.java

private void txtCapturaCurpKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCapturaCurpKeyTyped
    char caracter = evt.getKeyChar();
    if (Character.isDigit(caracter) || Character.isLetter(caracter)) {
        String texto = txtCapturaCurp.getText() + caracter;
        txtCapturaCurp.setText(texto.toUpperCase());
        evt.consume();//from  w  w w . j  av  a 2 s.co  m
        this.repaint();
    } else {
        getToolkit().beep();
        evt.consume();
    }
}