public void Letters(JTextField a) {
a.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(java.awt.event.KeyEvent e) {
char c = e.getKeyChar();
if (Character.isDigit(c)) {
e.consume();
}
if (Character.isLetter(c)) {
e.setKeyChar(Character.toUpperCase(c));
}
}
});
}
public void Numbers(JTextField a) {
a.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(java.awt.event.KeyEvent e) {
char c = e.getKeyChar();
if (!Character.isDigit(c)) {
e.consume();
}
}
});
}
public void Caracters(final JTextField a, final int lim) {
a.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(java.awt.event.KeyEvent ke) {
if (a.getText().length() == lim) {
ke.consume();
}
}
});
}