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

Stage doesn't respect its min/max size properties for its initial size

    XMLWordPrintable

    Details

    • Subcomponent:
    • Understanding:
      Cause Known
    • Introduced In Build:
      b151
    • Introduced In Version:
      9
    • CPU:
      generic
    • OS:
      windows

      Description

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+181)
      Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.15063]

      A DESCRIPTION OF THE PROBLEM :
      If the min/max size of the stage is set before the stage is shown, the stage won't respect these properties for its initial size. After you move or resize the window, the size adjusts.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the attached code.
      (2. Move or resize the window)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The initial size of the stage should be (600,600) because of the minHeight- and the minWidth-property.
      ACTUAL -
      The initial size of the stage is (400,400).

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class StageSizeBug extends Application{

          public static void main(String[] args){
              launch(args);
          }
          @Override
          public void start(Stage primaryStage) throws Exception {
              Label label = new Label("initial size of window is (400,400)\n" +
                      "->move or resize window\n" +
                      "->size of window changes to (600,600)\n" +
                      "EXPECTED: initial size should be (600,600)\n" +
                      "because of the minHeight- and the minWidth-property of the stage");
              StackPane pane = new StackPane(label);
              Scene scene = new Scene(pane,400,400);
              primaryStage.setScene(scene);

              primaryStage.setMinHeight(600);
              primaryStage.setMinWidth(600);

              //similar problem with
              //primaryStage.setMaxHeight(200);
              //primaryStage.setMaxWidth(200);

              primaryStage.show();

              //workaround: set properties here
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Set the properties after the stage is shown.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pbansal Pankaj Bansal
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: