Initial stage size set incorrectly for non-resizable stages

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 8
    • Component/s: javafx
    • None
    • Environment:

      Java8b129, Win7, ATI Radeon HD 4600

      See the Stackoverflow question for a description, test case and work-around:
          http://stackoverflow.com/questions/20732100/javafx-why-does-stage-setresizablefalse-cause-additional-margins

      ----------

      Test code:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;
      import javafx.scene.Group;

      public class ResizableStageAutoSizingTest extends Application {

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

          @Override
          public void start(final Stage primaryStage) throws Exception {
              final Rectangle rectangle = new Rectangle(200, 100, Color.POWDERBLUE);

      // if you use a Group, the content is in the top left corner with a white margins to the right and bottom.
              final Scene scene = new Scene(new Group(rectangle));

      // if you use a BorderPane instead of a Group, the content is centered with a white margins on all sides.
      // final BorderPane pane = new BorderPane(rectangle);
      // final Scene scene = new Scene(pane);

      // if the stage is not resizable, it will be correctly sized.
      // primaryStage.setResizable(false);

              primaryStage.setScene(scene);

      // workaround to fix issue.
      // primaryStage.sizeToScene();

              primaryStage.show();
          }
      }

            Assignee:
            Anthony Petrov (Inactive)
            Reporter:
            John Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: