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

[ScrollPane] ScrollPane fitToWidth causes incorrect layout (regression)

XMLWordPrintable

      Consider this simple test where I add a Label inside a Scrollpane which is itself inside an HBox.

      In 8u20 b17, the text is shrunk because of a layout problem. This was not the case in Lombard, it's a regression.
      Also note that it's the fact that the "fitToWidth" is set to true, and that the ScrollPane is inside an Hbox.

      Sample code:

      import javafx.application.Application;
      import static javafx.application.Application.launch;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.ScrollPane;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class TestScrollpane extends Application {

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

          @Override
          public void start(Stage stage) {

              Label label = new Label("This is a simple label");

              ScrollPane scrollPane = new ScrollPane(label);
              scrollPane.setFitToWidth(true);//This is causing the bug.
              HBox box = new HBox(scrollPane);
              Scene scene = new Scene(box);
              stage.setScene(scene);
              stage.show();
          }
      }

            jgiles Jonathan Giles
            shadzic Samir Hadzic
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: