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

VBox allocates additional top-margin for nested VBox when centered

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      javafx-sdk-11.0.2 - reproducible on latest LTS
      javafx-sdk-14.0.1 - reproducible on latest Release
      javafx-sdk-15 - reproducible on latest EA
      *********************************************************************************
      openjdk 14.0.2 2020-07-14
      OpenJDK Runtime Environment (build 14.0.2+11-45)
      OpenJDK 64-Bit Server VM (build 14.0.2+11-45, mixed mode, sharing)
      *********************************************************************************
      Operating System: Ubuntu 20.04 LTS
                        Kernel: Linux 5.4.0-40-generic
               Architecture: x86-64

      A DESCRIPTION OF THE PROBLEM :
      From VBox API doc: VBox lays out its children in a single vertical column.
      And It does so. But being aligned with 'Pos.BASELINE_CENTER' VBox allocates additional top-margin for another nested VBox. Height of that margin seems to be the same with that nested VBox's.
      You can find screenshots in related question from StackOverFlow: https://stackoverflow.com/questions/62842756/javafx-how-to-correctly-put-one-vbox-inside-another


      ---------- BEGIN SOURCE ----------
              VBox childVBox = new VBox(50.0);
              childVBox.setBackground(new Background(new BackgroundFill(Color.GREEN, null, null)));
              childVBox.getChildren().add(new Label("hell1"));
              childVBox.getChildren().add(new Label("hell2"));
              childVBox.getChildren().add(new Label("hell3"));

              VBox parentVBox = new VBox(20.0);
              parentVBox.setAlignment(Pos.BASELINE_CENTER);
              parentVBox.setBackground(new Background(new BackgroundFill(Color.ORANGE, null, null)));
              parentVBox.getChildren().add(new Label("JAVAFX v." + System.getProperties().get("javafx.runtime.version")));
              parentVBox.getChildren().add(new Separator());
              parentVBox.getChildren().add(childVBox);

              Scene scene = new Scene(parentVBox, 400, 400);
              primaryStage.setTitle("VBox Bug");
              primaryStage.setScene(scene);
              primaryStage.show();
      ---------- END SOURCE ----------

      FREQUENCY : always


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

              Created:
              Updated: