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

[HBox] Alignment behaviour changed when Pos.BASELINE_CENTER is used.

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • 8
    • 8
    • javafx
    • jdk 1.8.0-ea-b57

      To reproduce run the app. And look at the screenshots:

      import javafx.application.Application;
      import javafx.geometry.HPos;
      import javafx.geometry.Pos;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.CheckBox;
      import javafx.scene.control.CheckBoxBuilder;
      import javafx.scene.control.Label;
      import javafx.scene.control.RadioButton;
      import javafx.scene.control.ScrollPane;
      import javafx.scene.control.Separator;
      import javafx.scene.control.SeparatorBuilder;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;

      public class JavaApplication28 extends Application
      {

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

          @Override
          public void start(Stage stage) throws Exception
          {
              HBox hbox = new HBox(10d);
              hbox.getChildren().add(getScrollPane());

              Separator sep = SeparatorBuilder.create().halignment(HPos.CENTER).build();
              sep.setPrefWidth(80);
              hbox.getChildren().add(sep);


              CheckBox checkBox = CheckBoxBuilder.create()
                      .text("Check box the first line" + "\nthe sec long line" + "\nthe third line")
                      .graphic(new Rectangle(20, 20, Color.web("lightblue")))
                      .focusTraversable(false)
                      .build();
              hbox.getChildren().add(checkBox);
              hbox.setAlignment(Pos.BASELINE_CENTER);

              Scene scene = new Scene(hbox, 600, 400);
              stage.setScene(scene);
              stage.show();
          }

          private ScrollPane getScrollPane()
          {
              ScrollPane pane = new ScrollPane();
              HBox hbox = new HBox(30);
              VBox vbox1 = new VBox(10);
              vbox1.getChildren().addAll(new Label("one"), new Button("two"), new CheckBox("three"), new RadioButton("four"), new Label("five"));
              VBox vbox2 = new VBox(10);
              vbox2.getChildren().addAll(new Label("one"), new Button("two"), new CheckBox("three"), new RadioButton("four"), new Label("five"));
              hbox.getChildren().addAll(vbox1, vbox2);
              pane.setContent(hbox);
              pane.setFocusTraversable(false);
              return pane;
          }
      }

            msladecek Martin Sládeček
            dzinkevi Dmitry Zinkevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: