本文整理汇总了Java中javafx.scene.control.TextFormatter.Change方法的典型用法代码示例。如果您正苦于以下问题:Java TextFormatter.Change方法的具体用法?Java TextFormatter.Change怎么用?Java TextFormatter.Change使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TextFormatter
的用法示例。
在下文中一共展示了TextFormatter.Change方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@FXML
void initialize() {
UnaryOperator<TextFormatter.Change> filter = change -> {
String text = change.getText();
if (text.matches("[0-9]*")) {
return change;
}
return null;
};
TextFormatter<String> textFormatter1 = new TextFormatter<>(filter);
TextFormatter<String> textFormatter2 = new TextFormatter<>(filter);
controlPortTextField.setTextFormatter(textFormatter1);
framegrabPortTextField.setTextFormatter(textFormatter2);
load();
}
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:19,代码来源:SharktopodaSettingsPaneController.java
示例2: initialize
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@FXML
void initialize() {
UnaryOperator<TextFormatter.Change> filter = change -> {
String text = change.getText();
if (text.matches("[0-9]*")) {
return change;
}
return null;
};
TextFormatter<String> textFormatter1 = new TextFormatter<>(filter);
sequenceNumberTextField.setTextFormatter(textFormatter1);
cameraIdComboBox.setEditable(true);
}
示例3: apply
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@Override
public TextFormatter.Change apply(TextFormatter.Change change) {
if (change.getControlNewText().isEmpty()) {
return change;
}
String text = change.getControlNewText();
String[] split = text.split(" ");
if (split.length == 2 && change.getText().equals(" ")) {
return null;
}
if (Arrays.stream(split).allMatch(s -> {
if (s.startsWith("+")) {
s = s.substring(1);
if (s.isEmpty()) return true;
}
ParsePosition parsePosition = new ParsePosition(0);
Object object = format.parse(s, parsePosition);
return (!(object == null || parsePosition.getIndex() < s.length()));
})) {
return change;
}
return null;
}
示例4: initialize
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@FXML
public void initialize(URL url, ResourceBundle rb) {
UnaryOperator<TextFormatter.Change> filter = c -> {
String proposedText = c.getControlNewText();
if (proposedText.matches(".{0,15}")) {
return c ;
} else {
return null ;
}
};
namePlayer1.setTextFormatter(new TextFormatter<String>(filter));
namePlayer2.setTextFormatter(new TextFormatter<String>(filter));
}
示例5: initialize
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
UnaryOperator<TextFormatter.Change> filter = c -> {
String proposedText = c.getControlNewText();
if (proposedText.matches(".{0,15}")) {
return c ;
} else {
return null ;
}
};
playerName.setTextFormatter(new TextFormatter<String>(filter));
}
示例6: getFilter
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@Override
protected UnaryOperator<TextFormatter.Change> getFilter() {
return change -> {
final String newText = change.getControlNewText();
return newText.isEmpty() || newText.length() == 1 ? change : null;
};
}
示例7: apply
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@Override
public TextFormatter.Change apply(TextFormatter.Change change) {
if (change.getControlNewText().isEmpty()) {
return change;
}
ParsePosition parsePosition = new ParsePosition(0);
Object object = format.parse(change.getControlNewText(), parsePosition);
if (object == null || parsePosition.getIndex() < change.getControlNewText().length()) {
return null;
} else {
return change;
}
}
示例8: addInputValidation
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
/**
* Add Mac input field validations
*/
@Override
protected void addInputValidation() {
final UnaryOperator<TextFormatter.Change> ipAddressFilter = Util.getTextChangeFormatter(validateAddressRegex());
srcAddress.setTextFormatter(new TextFormatter<>(ipAddressFilter));
dstAddress.setTextFormatter(new TextFormatter<>(ipAddressFilter));
// add format for step and count
srcCount.setTextFormatter(Util.getNumberFilter(4));
dstCount.setTextFormatter(Util.getNumberFilter(4));
srcStep.setTextFormatter(Util.getNumberFilter(3));
dstStep.setTextFormatter(Util.getNumberFilter(3));
}
示例9: addInputValidation
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
/**
* Add input formatter instructions
*/
private void addInputValidation() {
UnaryOperator<TextFormatter.Change> unitFormatter = Util.getTextChangeFormatter(Util.getUnitRegex(false));
srcCountTF.setTextFormatter(new TextFormatter<>(unitFormatter));
dstCountTF.setTextFormatter(new TextFormatter<>(unitFormatter));
countTF.setTextFormatter(Util.getNumberFilter(5));
UnaryOperator<TextFormatter.Change> digitsFormatter = Util.getTextChangeFormatter(digitsRegex());
speedupTF.setTextFormatter(new TextFormatter<>(digitsFormatter));
ipgTF.setTextFormatter(new TextFormatter<>(digitsFormatter));
}
示例10: buildUI
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
/**
* Build multiplier view UI
*
* @param title
* @param group
*/
private void buildUI(String title, ToggleGroup group) {
// add radio button
selection = new RadioButton(title);
selection.setToggleGroup(group);
selection.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue) {
multiplierSelectionEvent.onMultiplierSelect(type);
}
value.setDisable(!newValue);
});
setTooltip();
getChildren().add(selection);
MultiplierOption.setTopAnchor(selection, 15d);
MultiplierOption.setLeftAnchor(selection, 0d);
// text field
value = new TextField();
value.setPrefSize(120, 22);
value.setDisable(true);
value.addEventFilter(KeyEvent.KEY_RELEASED, multiplierSelectionEvent.validateInput());
String regex = unitRegex();
final UnaryOperator<TextFormatter.Change> keyPressFilter = c -> {
String text = c.getControlNewText();
if (text.matches(regex)) {
return c;
} else {
return null;
}
};
value.setTextFormatter(new TextFormatter<>(keyPressFilter));
getChildren().add(value);
MultiplierOption.setTopAnchor(value, 43d);
MultiplierOption.setLeftAnchor(value, 0d);
MultiplierOption.setBottomAnchor(value, 15d);
}
示例11: getTextChangeFormatter
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
/**
* Return textChange formatter
*
* @param regex
* @return
*/
public static UnaryOperator<TextFormatter.Change> getTextChangeFormatter(String regex) {
return c -> {
String text = c.getControlNewText();
if (text.matches(regex)) {
return c;
} else {
return null;
}
};
}
示例12: getFilter
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@Override
protected UnaryOperator<TextFormatter.Change> getFilter() {
return change -> change;
}
示例13: addInputValidation
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
/**
* Add input validation for pattern
*/
@Override
protected void addInputValidation() {
final UnaryOperator<TextFormatter.Change> filter = Util.getTextChangeFormatter(validatePayloadPattern());
pattern.setTextFormatter(new TextFormatter<>(filter));
}
示例14: apply
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@Override
public Change apply(TextFormatter.Change aT) {
return DIGIT_PATTERN.matcher(aT.getText()).matches() ? aT : null;
}
示例15: getHexFilter
import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
/**
* Return hex filter
*
* @param numOfChar
* @return
*/
public static TextFormatter getHexFilter(int numOfChar) {
UnaryOperator<TextFormatter.Change> filter = Util.getTextChangeFormatter(hexRegex(numOfChar));
return new TextFormatter<>(filter);
}