SyntaxFix
Write A Post
Hire A Developer
Questions
This code works fine for me even if you try to copy/paste.
myTextField.textProperty().addListener((observable, oldValue, newValue) -> { if (!newValue.matches("\\d*")) { myTextField.setText(oldValue); } });