当前位置: 首页>>代码示例>>Java>>正文


Java VisValidatableTextField.setTextFieldFilter方法代码示例

本文整理汇总了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);
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:20,代码来源:IntSpinnerModel.java

示例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());
	}
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:36,代码来源:FloatSpinnerModel.java

示例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());
	}
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:35,代码来源:SimpleFloatSpinnerModel.java

示例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);
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:36,代码来源:SceneSettingsDialog.java


注:本文中的com.kotcrab.vis.ui.widget.VisValidatableTextField.setTextFieldFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。