Esempio n. 1
0
  @Override
  public void initUI() {
    AnchorPane anchorPane = new AnchorPane();
    anchorPane.setPrefHeight(90.0);
    anchorPane.setPrefWidth(384.0);

    Label label = new Label(getApplication().getMessageSource().getMessage("name.label"));
    TextField input = new TextField();
    input.setPrefWidth(200.0);

    Button button = new Button();
    button.setPrefWidth(200.0);
    JavaFXUtils.configure(
        button, (JavaFXAction) actionFor(controller, "sayHello").getToolkitAction());

    Label output = new Label();
    label.setPrefWidth(360.0);

    model.inputProperty().bindBidirectional(input.textProperty());
    model.outputProperty().bindBidirectional(output.textProperty());

    anchorPane.getChildren().addAll(label, input, button, output);

    setLeftAnchor(label, 14.0);
    setTopAnchor(label, 14.0);
    setLeftAnchor(input, 172.0);
    setTopAnchor(input, 11.0);
    setLeftAnchor(button, 172.0);
    setTopAnchor(button, 45.0);
    setLeftAnchor(output, 14.0);
    setTopAnchor(output, 80.0);

    Tab tab = new Tab("Java");
    tab.setGraphic(new FontAwesomeIcon(FontAwesome.FA_COFFEE));
    tab.setClosable(false);
    tab.setContent(anchorPane);
    parentView.getTabPane().getTabs().add(tab);
  }