java - How to filter a backspace keyboard input -


i have code gives message when key number pressed:

txtvalueofclause.addeventfilter(keyevent.key_typed, new eventhandler<keyevent>() {             @override             public void handle(keyevent t) {                 char ar[] = t.getcharacter().tochararray();                 char ch = ar[t.getcharacter().tochararray().length - 1];                 if (!(ch >= '0' && ch <= '9')) {                     system.out.println("the char entered not number");                     t.consume();                 }             }         }); 

now if press on wrong button , press backspace remove it, error message. how can add backspace input if statement?

i have found answer:

txtvalueofclause.addeventfilter(keyevent.key_typed, new eventhandler<keyevent>() {             @override             public void handle(keyevent t) {                 char ar[] = t.getcharacter().tochararray();                 char ch = ar[t.getcharacter().tochararray().length - 1];                 int codebackspace = ch;                 if (!(ch >= '0' && ch <= '9') && codebackspace!=8) {                      system.out.println("the char entered not number");                     t.consume();                 }             }         }); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - Show Soft Keyboard when EditText Appears -