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

[HBox] HBox baseline alignment doesn't work with Buttons that have large explicit preferred size

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u20
    • javafx
    • Windows 7 64-bit
      Java 8 b129

      Add labels and a button to an HBox with alignment set to BASELINE_LEFT.
      Make the preferred size of the Button larger than normal.
      Text is not aligned to the baseline.

      See the following test case:

      package hboxalignment;

      import javafx.application.Application;
      import javafx.geometry.Pos;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class HBoxAlignment extends Application {

      @Override
      public void start(Stage primaryStage) {
      Button tallButton = new Button("Tall button");
      tallButton.setPrefHeight(32);
      HBox hbox = new HBox(
      new Label("Label1"),
      new Label("Label2"),
      tallButton
      );

      hbox.setAlignment(Pos.BASELINE_LEFT);

      VBox vbox = new VBox(hbox);
      Scene scene = new Scene(vbox, 500, 250);

      primaryStage.setTitle("Hello World!");
      primaryStage.setScene(scene);
      primaryStage.show();
      }

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

      }

            Unassigned Unassigned
            swpalmer Scott Palmer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Imported: