當前位置: 首頁>>代碼示例>>Java>>正文


Java TextField.setTextFormatter方法代碼示例

本文整理匯總了Java中javafx.scene.control.TextField.setTextFormatter方法的典型用法代碼示例。如果您正苦於以下問題:Java TextField.setTextFormatter方法的具體用法?Java TextField.setTextFormatter怎麽用?Java TextField.setTextFormatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.TextField的用法示例。


在下文中一共展示了TextField.setTextFormatter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addNumericValidation

import javafx.scene.control.TextField; //導入方法依賴的package包/類
private static void addNumericValidation(TextField field) {
    field.getProperties().put("vkType", "numeric");
    field.setTextFormatter(new TextFormatter<>(c -> {
        if (c.isContentChange()) {
            if (c.getControlNewText().length() == 0) {
                return c;
            }
            try {
                Integer.parseInt(c.getControlNewText());
                return c;
            } catch (NumberFormatException e) {
            }
            return null;

        }
        return c;
    }));
}
 
開發者ID:comtel2000,項目名稱:mokka7,代碼行數:19,代碼來源:ChartViewPresenter.java

示例2: start

import javafx.scene.control.TextField; //導入方法依賴的package包/類
@Override
public void start(final Stage stage) throws Exception
{
    textField = new TextField();
    textField.setId("formatted");

    final MaskCharacter[] mask = MaskBuilder.newBuilder()
                                            .appendLiteral("\\")
                                            .appendDigit()
                                            .appendLiteral(",")
                                            .appendHexa()
                                            .appendLiteral(".")
                                            .appendLetter()
                                            .appendLiteral("$")
                                            .appendLetterOrDigit()
                                            .appendLiteral("!")
                                            .appendLowerCase()
                                            .appendUpperCase()
                                            .appendLiteral("U")
                                            .appendAny()
                                            .appendLiteral("^")
                                            .append(1, //
                                                    c -> (c == '-' || c == '+' || c == 'M' || c == 'P'),
                                                    c -> (c == '+' || c == 'P') ? 'P' : 'M', '_')
                                            .appendLiteral("/")
                                            .build();

    textField.setTextFormatter(new TextFormatter<>(new MaskTextFilter(textField, true, mask)));

    final Scene scene = new Scene(textField, 200, 50);
    stage.setScene(scene);
    stage.show();
}
 
開發者ID:ben12,項目名稱:infxnity,代碼行數:34,代碼來源:MaskTextFilterTest.java

示例3: initTextFormater

import javafx.scene.control.TextField; //導入方法依賴的package包/類
public static void initTextFormater(TextField textField, MaxActValue maxActValue) {
    textField.setTextFormatter(new TextFormatter<>(new NumberStringConverter()));
    textField.setTextFormatter(new TextFormatter<>(new NumberStringConverter(), null,
        FormUtils.integerFilter(
            maxActValue.getMinValue().intValue(),
            maxActValue.getMaxValue().intValue()
    )));
    textField.textProperty().bindBidirectional(maxActValue.actValueProperty(), new NumberStringConverter());
}
 
開發者ID:stechy1,項目名稱:drd,代碼行數:10,代碼來源:FormUtils.java


注:本文中的javafx.scene.control.TextField.setTextFormatter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。