Need help with ScrollPane sizing inside nested panes

Kevin Smith kevin.s at
Wed Sep 10 23:46:45 UTC 2014

If we have a Pane containing a ScrollPane containing a GridPane,
everything works as expected. But as soon as we inject a second Pane
(which is hard for us to avoid in this case), the ScrollPane no longer
grows to fit its space. See the example app below. Without "inner", it
works great.

Is there a simple way to get the ScrollPane to fill its parent?

I have tried every combination of prefWidth and prefViewportWidth that I
can think of, and I have tried Border Pane, and nothing has worked. I
have searched the web, but have been unable to find an answer to this.
If the answer is already out there, please feel free to just point me to

I just upgraded to Java 8u20, which didn't help.



public class FxScrollPaneTest extends Application
    public static void main(String[] args)

    public void start(Stage primaryStage)
        primaryStage.setTitle("Hello World!");
        GridPane grid = new GridPane();

        grid.add(new Label("upper left"), 0, 0);
        grid.add(new Label("upper right"), 1, 0);
        grid.add(new Label("lower left"), 0, 1);
        grid.add(new Label("lower left"), 1, 1);
        Pane root = new Pane();
        Pane inner = new Pane();
        ScrollPane scroller = new ScrollPane(grid);
        primaryStage.setScene(new Scene(root, 300, 250));;

More information about the openjfx-dev mailing list