I want to control the input into a Javafx TextField so that I can allow only Numeric input, and so that if the max characters are exceeded, then no change will be made to th
I simply set the 'On Key Typed' event to run this small procedure:
@FXML public void processKeyEvent(KeyEvent ev) { String c = ev.getCharacter(); if("1234567890".contains(c)) {} else { ev.consume(); } }
It works like a champ!