本文整理汇总了Java中com.kotcrab.vis.ui.widget.VisValidatableTextField.setTextFieldFilter方法的典型用法代码示例。如果您正苦于以下问题:Java VisValidatableTextField.setTextFieldFilter方法的具体用法?Java VisValidatableTextField.setTextFieldFilter怎么用?Java VisValidatableTextField.setTextFieldFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.kotcrab.vis.ui.widget.VisValidatableTextField
的用法示例。
在下文中一共展示了VisValidatableTextField.setTextFieldFilter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import com.kotcrab.vis.ui.widget.VisValidatableTextField; //导入方法依赖的package包/类
@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);
}
示例2: setScale
import com.kotcrab.vis.ui.widget.VisValidatableTextField; //导入方法依赖的package包/类
private void setScale (final int scale, boolean notifySpinner) {
if (scale < 0) throw new IllegalStateException("Scale can't be < 0");
this.scale = scale;
current = current.setScale(scale, BigDecimal.ROUND_HALF_UP);
VisValidatableTextField valueText = spinner.getTextField();
valueText.getValidators().clear();
valueText.addValidator(boundsValidator); //Both need the bounds check
if (scale == 0) {
valueText.addValidator(Validators.INTEGERS);
valueText.setTextFieldFilter(textFieldFilter = new IntDigitsOnlyFilter(true));
} else {
valueText.addValidator(Validators.FLOATS);
valueText.addValidator(new InputValidator() {
@Override
public boolean validateInput (String input) {
int dotIndex = input.indexOf('.');
if (dotIndex == -1) return true;
return input.length() - input.indexOf('.') - 1 <= scale;
}
});
valueText.setTextFieldFilter(textFieldFilter = new FloatDigitsOnlyFilter(true));
}
textFieldFilter.setUseFieldCursorPosition(true);
if (min.compareTo(BigDecimal.ZERO) >= 0) {
textFieldFilter.setAcceptNegativeValues(false);
} else {
textFieldFilter.setAcceptNegativeValues(true);
}
if (notifySpinner) {
spinner.notifyValueChanged(spinner.isProgrammaticChangeEvents());
}
}
示例3: setPrecision
import com.kotcrab.vis.ui.widget.VisValidatableTextField; //导入方法依赖的package包/类
private void setPrecision (final int precision, boolean notifySpinner) {
if (precision < 0) throw new IllegalStateException("Precision can't be < 0");
this.precision = precision;
VisValidatableTextField valueText = spinner.getTextField();
valueText.getValidators().clear();
valueText.addValidator(boundsValidator); //Both need the bounds check
if (precision == 0) {
valueText.addValidator(Validators.INTEGERS);
valueText.setTextFieldFilter(textFieldFilter = new IntDigitsOnlyFilter(true));
} else {
valueText.addValidator(Validators.FLOATS);
valueText.addValidator(new InputValidator() {
@Override
public boolean validateInput (String input) {
int dotIndex = input.indexOf('.');
if (dotIndex == -1) return true;
return input.length() - input.indexOf('.') - 1 <= precision;
}
});
valueText.setTextFieldFilter(textFieldFilter = new FloatDigitsOnlyFilter(true));
}
textFieldFilter.setUseFieldCursorPosition(true);
if (min >= 0) {
textFieldFilter.setAcceptNegativeValues(false);
} else {
textFieldFilter.setAcceptNegativeValues(true);
}
if (notifySpinner) {
spinner.notifyValueChanged(spinner.isProgrammaticChangeEvents());
}
}
示例4: createUI
import com.kotcrab.vis.ui.widget.VisValidatableTextField; //导入方法依赖的package包/类
@Override
protected void createUI () {
viewportModeSelectBox = new EnumSelectBox<>(SceneViewport.class, new PrettyEnumNameProvider<>());
viewportModeSelectBox.setSelectedEnum(scene.viewport);
//TODO error msg can't fit on window, for now we don't display it at all
errorLabel = new VisLabel();
errorLabel.setColor(Color.RED);
TableUtils.setSpacingDefaults(this);
columnDefaults(0).left();
row().padTop(4);
add(new VisLabel("Viewport"));
add(viewportModeSelectBox).expand().fill();
row();
widthField = new VisValidatableTextField(String.valueOf(scene.width));
heightField = new VisValidatableTextField(String.valueOf(scene.height));
widthField.setTextFieldFilter(new FloatDigitsOnlyFilter(false));
heightField.setTextFieldFilter(new FloatDigitsOnlyFilter(false));
VisTable sizeTable = new VisTable(true);
add(new VisLabel("Width"));
sizeTable.add(widthField).width(60);
sizeTable.add(new VisLabel("Height"));
sizeTable.add(heightField).width(60);
add(sizeTable).expand().fill();
row();
add(getButtonTable()).colspan(2).fill().expand();
padBottom(5);
}