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


Java TextField.setMaxHeight方法代码示例

本文整理汇总了Java中javafx.scene.control.TextField.setMaxHeight方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setMaxHeight方法的具体用法?Java TextField.setMaxHeight怎么用?Java TextField.setMaxHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.TextField的用法示例。


在下文中一共展示了TextField.setMaxHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WebViewPane

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:WebViewBrowser.java

示例2: StringBindingSample

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public StringBindingSample() {
    final SimpleDateFormat format = new SimpleDateFormat("mm/dd/yyyy");
    final TextField dateField = new TextField();
    dateField.setPromptText("Enter a birth date");
    dateField.setMaxHeight(TextField.USE_PREF_SIZE);
    dateField.setMaxWidth(TextField.USE_PREF_SIZE);

    Label label = new Label();
    label.textProperty().bind(new StringBinding() {
        {
            bind(dateField.textProperty());
        }            
        @Override protected String computeValue() {
            try {
                Date date = format.parse(dateField.getText());
                Calendar c = Calendar.getInstance();
                c.setTime(date);

                Date today = new Date();
                Calendar c2 = Calendar.getInstance();
                c2.setTime(today);

                if (c.get(Calendar.DAY_OF_YEAR) == c2.get(Calendar.DAY_OF_YEAR) - 1
                        && c.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
                    return "You were born yesterday";
                } else {
                    return "You were born " + format.format(date);
                }
            } catch (Exception e) {
                return "Please enter a valid birth date (mm/dd/yyyy)";
            }
        }
    });

    VBox vBox = new VBox(7);
    vBox.setPadding(new Insets(12));
    vBox.getChildren().addAll(label, dateField);
    getChildren().add(vBox);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:40,代码来源:StringBindingSample.java

示例3: TextValidatorSample

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public TextValidatorSample() {
    String validatorCss = TextValidatorSample.class.getResource("Validators.css").toExternalForm();
    
    TextField dateField = new TextField();
    dateField.setPromptText("Enter a Large Number");
    dateField.setMaxHeight(TextField.USE_PREF_SIZE);

    TextInputValidatorPane<TextField> pane = new TextInputValidatorPane<TextField>();
    pane.setContent(dateField);
    pane.setValidator(new Validator<TextField>() {
        public ValidationResult validate(TextField control) {
            try {
                String text = control.getText();
                if (text == null || text.trim().equals("")) return null;
                double d = Double.parseDouble(text);
                if (d < 1000) {
                    return new ValidationResult("Should be > 1000", ValidationResult.Type.WARNING);
                }
                return null; // succeeded
            } catch (Exception e) {
                // failed
                return new ValidationResult("Bad number", ValidationResult.Type.ERROR);
            }
        }
    });

    StackPane rootSP = new StackPane();
    rootSP.setPadding(new Insets(12));
    rootSP.getChildren().add(pane);
    pane.getStylesheets().add(validatorCss);
    getChildren().add(rootSP);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:33,代码来源:TextValidatorSample.java


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