Ejemplo n.º 1
0
 /**
  * @param icon
  * @param height
  * @param width
  * @return
  */
 public static ImageView getImage(String icon, double height, double width) {
   ImageView image = new ImageView(ResourceLoader.getImage(icon));
   image.fitHeightProperty().set(height);
   image.fitWidthProperty().set(width);
   return image;
 }
Ejemplo n.º 2
0
  /**
   * @param owner
   * @param title
   * @param titleLong
   * @param message
   * @return
   */
  public Response show(Stage owner, String title, String titleLong, String message) {
    final Stage stage = new Stage();

    final BooleanProperty isOK = new SimpleBooleanProperty(false);

    stage.setTitle(title);
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.initOwner(owner);

    //        BorderPane root = new BorderPane();
    VBox root = new VBox();

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setWidth(500);
    stage.setHeight(250);
    stage.initStyle(StageStyle.UTILITY);
    stage.setResizable(false);

    Node header = DialogHeader.getDialogHeader(ICON, titleLong);

    ImageView imageView = ResourceLoader.getImage(ICON, 65, 65);
    stage.getIcons().add(imageView.getImage());

    HBox buttonPanel = new HBox();

    Button ok = new Button("OK");
    ok.setDefaultButton(true);

    buttonPanel.getChildren().addAll(ok);
    buttonPanel.setAlignment(Pos.CENTER_RIGHT);
    buttonPanel.setPadding(new Insets(10, 10, 10, 10));
    buttonPanel.setSpacing(10);
    buttonPanel.setMaxHeight(25);

    HBox messagePanel = new HBox();
    messagePanel.setPadding(new Insets(30, 30, 30, 30));

    Label mewssage = new Label(message);
    messagePanel.getChildren().add(mewssage);
    mewssage.setWrapText(true);
    mewssage.setAlignment(Pos.CENTER_LEFT);

    Separator sep = new Separator(Orientation.HORIZONTAL);
    sep.setMinHeight(10);

    root.getChildren()
        .addAll(header, new Separator(Orientation.HORIZONTAL), messagePanel, buttonPanel);
    VBox.setVgrow(messagePanel, Priority.ALWAYS);
    VBox.setVgrow(buttonPanel, Priority.NEVER);
    VBox.setVgrow(header, Priority.NEVER);

    ok.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
            //                System.out.println("Size: h:" + stage.getHeight() + " w:" +
            // stage.getWidth());
            stage.close();
            //                isOK.setValue(true);
            response = Response.OK;
          }
        });

    stage.showAndWait();

    return response;
  }