Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8274669

Dialog sometimes ignores max height

XMLWordPrintable

    • generic
    • generic

      Dialogs sometimes ignores the max height when the pref height of the dialog content is bigger.
      This will lead to a visual glitch where the dialog is flickering between the max height and the pref height.
      -----
      - First layout pass: The dialog will incorrectly resize to a the pref height, which is bigger than the max height.
      - Second layout pass: The dialog will correctly resize to the max height
      ... (repeat)

      --- TESTCASE SOURCE START ---
      import javafx.application.Application;
      import javafx.scene.control.ButtonType;
      import javafx.scene.control.Dialog;
      import javafx.scene.control.Label;
      import javafx.scene.layout.Background;
      import javafx.scene.layout.BackgroundFill;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.StackPane;
      import javafx.scene.paint.Color;
      import javafx.stage.Stage;

      public class ScrollPaneApp extends Application {

          public static void run(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage primaryStage) throws Exception {
              StackPane stackPane = new StackPane();
              stackPane.setBackground(new Background(new BackgroundFill(Color.RED, null, null)));
              stackPane.setPrefHeight(700);

              Dialog<ButtonType> dialog = new Dialog<>();

              dialog.getDialogPane().setContent(stackPane);
              dialog.getDialogPane().setMaxHeight(400);

              dialog.show();
          }
      }
      --- TESTCASE SOURCE END---

            mhanl Marius Hanl
            mhanl Marius Hanl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: