-
Notifications
You must be signed in to change notification settings - Fork 128
VisValidatableTextField
Pawel Pastuszak edited this page Dec 7, 2018
·
5 revisions
VisValidatableTextField
(source) is a text field that input can be validated, input validation is done by implementation of InputValidator
. Text field can have any number of validators, if any of them return that input is invalid, field border is changed to red. Demo
Demo source:
//field creation
textField = new VisValidatableTextField(new IntegerValidator());
//validator implementation
public class IntegerValidator implements InputValidator {
@Override
public boolean validateInput (String input) {
try {
Integer.parseInt(input);
return true;
} catch (NumberFormatException e) {
return false;
}
}
}
The following validators are located in Validators
class: (since VisUI 0.6.0)
IntegerValidator
FloatValidator
-
GreaterThanValidator
(may also be used as greater or equal) -
LesserThanValidator
(may also be used as lesser or equal)
One instance of validator may be shared between text fields. You can use static final fields Validators.INTEGERS
and Validators.FLOATS
.
See README for VisUI introduction.