private TextInput textinputIntRange = null;
private TextInput textinputDateRegex = null;
private TextInput textinputCustomBoolean = null;
public void startup(Display display, Dictionary<String, String> properties) throws Exception {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
window = new Window((Component)wtkxSerializer.readObject(
getClass().getResource("textInputValidator_test.wtkx")));
textinputFloatRange = (TextInput)wtkxSerializer.getObjectByID("textinputFloatRange");
textinputIntRange = (TextInput)wtkxSerializer.getObjectByID("textinputIntRange");
textinputDateRegex = (TextInput)wtkxSerializer.getObjectByID("textinputDateRegex");
textinputCustomBoolean = (TextInput)wtkxSerializer.getObjectByID("textinputCustomBoolean");
// standard float range model
textinputFloatRange.setText("0.5");
textinputFloatRange.setValidator(new FloatRangeValidator(0.3f, 2000f));
// test the listener by updating a label
textinputFloatRange.getTextInputListeners().add(new TextInputListener() {
public void maximumLengthChanged(TextInput textInput, int previousMaximumLength) {
}
public void passwordChanged(TextInput textInput) {
}
public void promptChanged(TextInput textInput, String previousPrompt) {
}
public void textKeyChanged(TextInput textInput, String previousTextKey) {
}
public void textNodeChanged(TextInput textInput, TextNode previousTextNode) {
}
public void textSizeChanged(TextInput textInput, int previousTextSize) {
}
public void textValidChanged(TextInput textInput) {
invalidLabel.setText(textInput.isTextValid() ? "valid" : "invalid");
}
public void textValidatorChanged(TextInput textInput, Validator validator) {
}
});
invalidLabel = (Label)wtkxSerializer.getObjectByID("invalidLabel");
// standard int range model
textinputIntRange.setText("0");
textinputIntRange.setValidator(new IntRangeValidator(0, 100));