Пример #1
2
  public static void message(String msg, StackPane pane) {

    Label warningL = new Label(msg);
    Labels.setLabelStyle(warningL, Custom.TEXT_SIZE_LARGER, true);
    warningL.setTextAlignment(TextAlignment.CENTER);

    StackPane warningPane = new StackPane();
    warningPane.getChildren().add(warningL);
    warningPane.setStyle(Custom.WINDOW_STYLING);
    warningPane.setMinWidth(Custom.SCREEN_WIDTH * 95 / 100);
    warningPane.setMaxWidth(Custom.SCREEN_WIDTH * 95 / 100);
    warningPane.setMinHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    warningPane.setMaxHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    warningPane.setBorder(
        new Border(
            new BorderStroke(
                Paint.valueOf("#000000"),
                BorderStrokeStyle.SOLID,
                new CornerRadii(30),
                new BorderWidths(5))));

    pane.getChildren().add(warningPane);

    PauseTransition pause = new PauseTransition(Duration.millis(1500));
    pause.setOnFinished(
        (f) -> {
          pane.getChildren().remove(warningPane);
          goBack();
        });
    pause.play();
  }
Пример #2
1
  public static void setPayPane(int amount) {

    message = new Label(Custom.PAY_PTS_MESSAGE);
    Labels.setLabelStyle(message, Custom.TEXT_SIZE_LARGER, true);
    StackPane.setAlignment(message, Pos.CENTER);

    payBtn = new Button(Custom.YES);
    Buttons.setStoreLargerButtons(payBtn, true);
    StackPane.setAlignment(payBtn, Pos.BOTTOM_LEFT);
    payBtn.setOnAction((ae) -> PayPoints.buy(amount));

    backBtn = new Button(Custom.NO);
    Buttons.setStoreLargerButtons(backBtn, true);
    StackPane.setAlignment(backBtn, Pos.BOTTOM_RIGHT);
    backBtn.setOnAction((ae) -> PayPoints.goBack());

    mainPane = new StackPane();
    mainPane.setStyle(Custom.WINDOW_STYLING);
    mainPane.setMinWidth(Custom.SCREEN_WIDTH * 95 / 100);
    mainPane.setMaxWidth(Custom.SCREEN_WIDTH * 95 / 100);
    mainPane.setMinHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    mainPane.setMaxHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    mainPane.setBorder(
        new Border(
            new BorderStroke(
                Paint.valueOf("#000000"),
                BorderStrokeStyle.SOLID,
                new CornerRadii(30),
                new BorderWidths(5))));
    mainPane.getChildren().addAll(message, payBtn, backBtn);
    mainPane.setPadding(new Insets(10, 10, 10, 10));
    StackPane.setAlignment(mainPane, Pos.CENTER);

    backPane = new StackPane();
    backPane.getChildren().add(mainPane);
    backPane.setStyle(Custom.MENU_BACKGROUND);

    getRoot().getChildren().add(backPane);
  }
  public void endInteraction() {
    assert scalingGroup.getParent().isManaged() == false;

    // Reverts the top stack pane : it now adjusts to the size of its children
    final StackPane contentPane = (StackPane) scrollPane.getContent();
    assert contentPane.getMinWidth() == Region.USE_PREF_SIZE;
    assert contentPane.getMinHeight() == Region.USE_PREF_SIZE;
    assert contentPane.getPrefWidth() != Region.USE_COMPUTED_SIZE;
    assert contentPane.getPrefHeight() != Region.USE_COMPUTED_SIZE;
    assert contentPane.getMaxWidth() == Region.USE_PREF_SIZE;
    assert contentPane.getMaxHeight() == Region.USE_PREF_SIZE;
    contentPane.setPrefWidth(Region.USE_COMPUTED_SIZE);
    contentPane.setPrefHeight(Region.USE_COMPUTED_SIZE);
    contentPane.setMaxWidth(Double.MAX_VALUE);
    contentPane.setMaxHeight(Double.MAX_VALUE);

    // Reverts scalingGroup setup
    scalingGroup.getParent().setManaged(true);
  }
  public void beginInteraction() {
    assert scalingGroup.getParent().isManaged();
    assert scrollPane.getContent() instanceof StackPane;

    // Makes the user design and enclosing group unmanaged so
    // that they no longer influence the scroll pane viewport.
    scalingGroup.getParent().setManaged(false);

    // Renders the top stack pane fully rigid
    final StackPane contentPane = (StackPane) scrollPane.getContent();
    assert contentPane.getMinWidth() == Region.USE_PREF_SIZE;
    assert contentPane.getMinHeight() == Region.USE_PREF_SIZE;
    assert contentPane.getPrefWidth() == Region.USE_COMPUTED_SIZE;
    assert contentPane.getPrefHeight() == Region.USE_COMPUTED_SIZE;
    assert contentPane.getMaxWidth() == Double.MAX_VALUE;
    assert contentPane.getMaxHeight() == Double.MAX_VALUE;
    contentPane.setPrefWidth(contentPane.getWidth());
    contentPane.setPrefHeight(contentPane.getHeight());
    contentPane.setMaxWidth(Region.USE_PREF_SIZE);
    contentPane.setMaxHeight(Region.USE_PREF_SIZE);
  }
  protected Node buildButton(String url, double ancho, double largo, boolean focus) {

    String cadena = "Imagenes/Botones/" + url;
    final StackPane boton = new StackPane();
    boton.setMaxWidth(ancho);
    boton.setMaxHeight(largo);

    StackPane stackPane =
        StackPaneBuilder.create()
            .children(
                ImageViewBuilder.create()
                    .cursor(Cursor.HAND)
                    .image(new Image(getClass().getResource(cadena).toString()))
                    .fitWidth(ancho)
                    .fitHeight(largo)
                    .build())
            .focusTraversable(focus)
            .onMousePressed(
                new EventHandler<Event>() {

                  public void handle(Event event) {
                    boton.setOpacity(.6f);
                  }
                })
            .onMouseReleased(
                new EventHandler<Event>() {

                  @Override
                  public void handle(Event event) {
                    boton.setOpacity(1);
                  }
                })
            .build();
    boton.getChildren().add(stackPane);
    return boton;
  }