VisValidatableTextField

Paweł Pastuszak edited this page Jun 26, 2016 · 4 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;
		}
	}
}

Built-in validators

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.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.