How can you set a TextArea in JavaFX to allow only integers to be entered? -
this question has answer here:
i trying create textarea in javafx accepts integer values? can give me advice how implement this?
use textformatter
:
textarea textarea = new textarea(); // allow digits , whitespace: pattern allowedtext = pattern.compile("[0-9\\s]*"); textformatter formatter = new textformatter((textformatter.change c) -> { if (allowedtext.matcher(c.gettext()).matches()) { return c ; } else { return null ; } });
Comments
Post a Comment