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


Java TextFormatter.Change方法代码示例

本文整理汇总了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);
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:17,代码来源:MediaParamsPaneController.java

示例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;
}
 
开发者ID:m-krajcovic,项目名称:photometric-data-retriever,代码行数:25,代码来源:CoordsFilter.java

示例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));
}
 
开发者ID:Plinz,项目名称:Hive_Game,代码行数:14,代码来源:NewGameScreenController.java

示例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));   
}
 
开发者ID:Plinz,项目名称:Hive_Game,代码行数:16,代码来源:NetworkScreenController.java

示例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;
    };
}
 
开发者ID:LanternPowered,项目名称:LanternNBT,代码行数:8,代码来源:CharConverter.java

示例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;
    }
}
 
开发者ID:m-krajcovic,项目名称:photometric-data-retriever,代码行数:15,代码来源:DecimalFilter.java

示例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));
}
 
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:16,代码来源:MacProtocolView.java

示例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));

}
 
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:16,代码来源:ImportedPacketPropertiesView.java

示例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);
}
 
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:44,代码来源:MultiplierOption.java

示例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;
        }
    };
}
 
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:17,代码来源:Util.java

示例12: getFilter

import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@Override
protected UnaryOperator<TextFormatter.Change> getFilter() {
    return change -> change;
}
 
开发者ID:LanternPowered,项目名称:LanternNBT,代码行数:5,代码来源:StringConverter.java

示例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));
}
 
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:9,代码来源:PayloadView.java

示例14: apply

import javafx.scene.control.TextFormatter; //导入方法依赖的package包/类
@Override
public Change apply(TextFormatter.Change aT) {
    return DIGIT_PATTERN.matcher(aT.getText()).matches() ? aT : null;
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:5,代码来源:OnlyIntegerFormatter.java

示例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);
}
 
开发者ID:exalt-tech,项目名称:trex-stateless-gui,代码行数:11,代码来源:Util.java


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