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

Computed preferred height of BorderPane is too small in a specific situation

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_60-ea"
      Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b25)
      Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      In most cases, the computation of the preferred height of a BorderPane works fine. However, when (left/right) paddings are set on a BorderPane and it contains a (center) child whose height would be smaller if it could use the free area of the paddings for its content, the preferred height of the BorderPane is too small.

      (Different to VBox, HBox and StackPane, the left and right insets of the BorderPane don't seem to be respected for the computation of the preferred height. The width which is passed to computePrefHeight(..) of BorderPane is given via getAreaHeight(..) to computeChildPrefAreaHeight(..) without any subtractions regarding the insets of the BorderPane. By the way, the top and bottom insets also don't seem to be subtracted from the height given to computePrefWidth(..) of BorderPane. Isn't this necessary?)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please run the provided sample code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The text of the label should be completely visible and consist of three lines.
      ACTUAL -
      The text of the label is truncated with an ellipsis and consists only of two lines.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.geometry.Insets;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class LabelWrapTextTester extends Application {

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

          @Override
          public void start(Stage primaryStage) {
              Label label = new Label("This is a long text which should be completely visible without any ellipsis even when insets are set.");
              label.setWrapText(true);

              Pane labelPane = new VBox(label);
              labelPane.setPrefWidth(254.0);

              Pane rootPane = new BorderPane(labelPane);
              rootPane.setPadding(new Insets(20.0));

              primaryStage.setScene(new Scene(rootPane));
              primaryStage.show();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      When a VBox, an HBox or a StackPane is used instead of the BorderPane, the label is displayed as expected.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: