Skip to content

Instantly share code, notes, and snippets.

@nosdoska
Created December 9, 2015 04:17
Show Gist options
  • Save nosdoska/fee40171a2c3c227aa47 to your computer and use it in GitHub Desktop.
Save nosdoska/fee40171a2c3c227aa47 to your computer and use it in GitHub Desktop.
public JOptionPane validarLetra(java.awt.event.KeyEvent evt) {
char c = evt.getKeyChar();
if (Character.isDigit(c)) {
getToolkit().beep();
evt.consume();
JOptionPane.showMessageDialog(rootPane, "Digite sólo letras.");
}
return null;
}
public JOptionPane validarNumero(java.awt.event.KeyEvent evt) {
char c = evt.getKeyChar();
if (Character.isLetter(c)) {
getToolkit().beep();
evt.consume();
JOptionPane.showMessageDialog(rootPane, "Digite sólo números.");
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment