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

Baseline alignment is broken for HBox in a GridPane row

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • 9
    • 8
    • javafx
    • Windows 7 64-bit
      Java Version: 1.8.0-ea-b114
      JavaFX Version: 8.0.0-ea-b114

    Description

      The baseline position for an HBox appears to be treated as 0. In JavaFX 2.2. the baseline position of the contained component was used.

      Consider an HBox constructed as so:

      HBox hbox = new HBox(2);
      hbox.setAlignment(Pos.CENTER_LEFT);
      hbox.getChildren().addAll(textField, slider);
      HBox.setHgrow(textField, Priority.SOMETIMES);
      HBox.setHgrow(slider, Priority.SOMETIMES);

      Placing this in a GridPane row with a Label in one column and the HBox in the next results in the label text aligning with the top pixel of the HBox instead of the baseline of the TextField. E.g.

      Label
                textField slider

      instead of:

      label textField slider

      Note that the HBox itself cannot use BASELINE alignment because that messes up the alignment of the TextField with the Slider. This is likely the root of the problem, but it works in JavaFX 2.2. In any case the top of the HBox is always wrong for the baseline. I recall a discussion on the OpenJFX mailing list about BASELINE_OFFSET_SAME_AS_HEIGHT for example - suggesting that when it can't be computed otherwise the bottom edge of the container should be used. (It would still be ugly in my case, but it would be better.)

      Attachments

        Activity

          People

            msladecek Martin Sládeček
            swpalmer Scott Palmer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: