Whenever I press backspace in the text box this code is triggered.
private void txtAgeKeyTyped(java.awt.event.KeyEvent evt) {
char agetext= evt.getKeyChar();
if(!(Character.isDigit(agetext))){
evt.consume();
JOptionPane.showMessageDialog(null,"Age is only written in Numbers!");
}
}
It should only be triggered if I typed Alphabets instead of Numbers only.
For some reason it is triggering whenever I press the Backspace Key.
Is there a way for me to use backspace without triggering this block of code?
I'm sorry this is the first time i fiddled with Key Events