I'm trying to implement a textfield like this one :
TextField Validation http://imageshack.com/a/img537/8329/FSht8P.png
My goal is to identify if the text of the TextField is a Double
or something else (then it appears in red).
I want to use ControlsFX to learn the library and to not edit the css, but it doesn't work very well, and I'm lost in the javadoc. Does anyone have an example or can help me improve my code ?
Here what I tried to do :
Validator<Double> checkTextField = new Validator<Double>() {
@Override
public ValidationResult apply(Control t, Double u) {
ValidationResult vd = new ValidationResult();
if(Double.valueOf(t.toString()) != null){
vd.addErrorIf(t, "false", false);
}
return vd;
}
};
ValidationSupport validationSupport = new ValidationSupport();
validationSupport.registerValidator(latitudeTextField, checkTextField/*Validator.createEmptyValidator("Text is required")*/);
ValidationDecoration iconDecorator = new GraphicValidationDecoration();
ValidationDecoration cssDecorator = new StyleClassValidationDecoration();
ValidationDecoration compoundDecorator = new CompoundValidationDecoration(cssDecorator, iconDecorator);
validationSupport.setValidationDecorator(compoundDecorator);