I want to set javaFX text field upto two decimal places . I found the answer but it is for numeric value . e-g
// force the field to be numeric only
textFie
I couldn't resist. This is aboves answer in two lines (the ones that do all the work)
private static TextFormatter new3DecimalFormatter(){
Pattern decimalPattern = Pattern.compile("-?\\d*(\\.\\d{0,3})?");
return new TextFormatter<>(c -> (decimalPattern.matcher(c.getControlNewText()).matches()) ? c : null );
}