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

Scene set after stage shown is not sized correctly with HiDPI scaling

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b96
    • Introduced In Version:
      9
    • CPU:
      generic
    • OS:
      windows

      Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7, professional, 64 bit

      A DESCRIPTION OF THE PROBLEM :
      If the scene is set on the stage AFTER it is shown it is not sized correctly.

      (Background: This was discovered during unit testing with the testFX framework which reuses the same stage for multiple tests with different scenes).

      This appears to be a regression. The same code running on Java 8u144 works as expected.

      REGRESSION. Last worked in version 8u151

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_144"
      Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
      Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test case

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      StackPane should fill the window exactly, i.e. the red border should sit just inside the Stage.
      ACTUAL -
      StackPane appears larger that the stage.
      If you resize the stage manually then the StackPane adjusts and is rendered correctly.

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- 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 SceneSizeIssue extends Application {

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

          @Override
          public void start(Stage stage) throws Exception {
              stage.setX(50);
              stage.setY(50);
              stage.setWidth(400);
              stage.setHeight(300);

              stage.show();

              StackPane box = new StackPane(new Label("Rigby"));
              box.setStyle("-fx-border-color: red");
              stage.setScene(new Scene(box));

          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Hide the stage and then show it again

        Attachments

        1. SceenSize_JDK11-ea+3.png
          45 kB
          Priyanka Mangal
        2. SceneSizeIssue.java
          0.7 kB
          Priyanka Mangal

          Issue Links

            Activity

              People

              Assignee:
              arapte Ambarish Rapte
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: