Java Code Examples for com.vaadin.ui.TextField#setMaxLength()

The following examples show how to use com.vaadin.ui.TextField#setMaxLength() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java    From gantt with Apache License 2.0 6 votes vote down vote up
public static TextField createNumberEditor(String caption, float value, final Component component,
        final NumberValueChange valueChange) {
    TextField field = new TextField(caption);
    field.setMaxLength(5);
    field.setValue("" + value);
    field.addValueChangeListener(new ValueChangeListener<String>() {

        @Override
        public void valueChange(ValueChangeEvent<String> event) {
            Object v = event.getValue();
            try {
                float f = Float.parseFloat("" + v);
                valueChange.onValueChange(f);
            } catch (NumberFormatException e) {
                Notification.show("Invalid floating number! Format is 123.345");
            }
        }
    });
    return field;
}
 
Example 2
Source File: AddUpdateRolloutWindowLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private TextField createErrorThreshold() {
    final TextField errorField = createIntegerTextField("prompt.error.threshold",
            UIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_ID);
    errorField.addValidator(new ThresholdFieldValidator());
    errorField.setMaxLength(7);
    errorField.setValue(defaultRolloutGroupConditions.getErrorConditionExp());
    return errorField;
}
 
Example 3
Source File: AddUpdateRolloutWindowLayout.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private TextField createNoOfGroupsField() {
    final TextField noOfGroupsField = createIntegerTextField("prompt.number.of.groups",
            UIComponentIdProvider.ROLLOUT_NO_OF_GROUPS_ID);
    noOfGroupsField.addValidator(new GroupNumberValidator());
    noOfGroupsField.addValidator(new GroupSizeValidator());
    noOfGroupsField.setMaxLength(3);
    noOfGroupsField.addValueChangeListener(this::onGroupNumberChange);
    return noOfGroupsField;
}