コード例 #1
0
  private void showError(List<String> errorList) {
    String msg = "";
    if (errorList.isEmpty()) {
      msg = "No message to display.";
    } else {
      for (String s : errorList) {
        msg = msg + s + "\n";
      }
    }
    Label msgLbl = new Label(msg);
    Button okBtn = new Button("OK");
    VBox root = new VBox(new StackPane(msgLbl), new StackPane(okBtn));
    root.setSpacing(10);

    Scene scene = new Scene(root);
    Stage stage = new Stage(StageStyle.UTILITY);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.setScene(scene);
    stage.initOwner(view.getScene().getWindow());

    // Set the Action listener for the OK button
    okBtn.setOnAction(e -> stage.close());

    stage.setTitle("Error");
    stage.sizeToScene();
    stage.showAndWait();
  }
コード例 #2
0
  private void attachEvents() {

    // We need to detect the birth date change when the bDate field loses
    // focus or the user presses the Enter key while it still has focus
    view.bDateFld.setOnAction(e -> handleBirthDateChange());
    view.bDateFld.getScene().focusOwnerProperty().addListener(this::focusChanged);

    view.saveBtn.setOnAction(e -> saveData());

    view.closeBtn.setOnAction(e -> view.getScene().getWindow().hide());
  }