Search in sources :

Example 1 with IntDigitsOnlyFilter

use of com.kotcrab.vis.ui.util.IntDigitsOnlyFilter in project vis-ui by kotcrab.

the class IntSpinnerModel method bind.

@Override
public void bind(Spinner spinner) {
    super.bind(spinner);
    VisValidatableTextField valueText = spinner.getTextField();
    valueText.getValidators().clear();
    valueText.addValidator(boundsValidator);
    valueText.addValidator(Validators.INTEGERS);
    valueText.setTextFieldFilter(textFieldFilter = new IntDigitsOnlyFilter(true));
    textFieldFilter.setUseFieldCursorPosition(true);
    if (min >= 0) {
        textFieldFilter.setAcceptNegativeValues(false);
    } else {
        textFieldFilter.setAcceptNegativeValues(true);
    }
    spinner.notifyValueChanged(true);
}
Also used : IntDigitsOnlyFilter(com.kotcrab.vis.ui.util.IntDigitsOnlyFilter) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField)

Aggregations

IntDigitsOnlyFilter (com.kotcrab.vis.ui.util.IntDigitsOnlyFilter)1 VisValidatableTextField (com.kotcrab.vis.ui.widget.VisValidatableTextField)1