0
votes

I want a ScrollPane in my application window which doesn't fill the whole scene, but only takes up part of it, because I want to place a button beneath it.

Like in this sketch: https://i.imgur.com/eUA7Af7.png

I tried using a GridPane, but I can only put Nodes as children of the GridPane, which doesn't work because the ScrollPane is not a Node.

public void start(Stage stage) throws Exception {
    var root = new GridPane();
    var scene = new Scene(root, 400, 400);

    var scrollPane = new ScrollPane();
    root.add(scrollPane, 0, 0); // Not possible

    var button = new Button();
    root.add(button, 0, 1);

    stage.setScene(scene);
    stage.show();
}
1
javafx.scene.control.ScrollPane definitely is a javafx.scene.Node. The class hierarchy is: ScrollPaneControlRegionParentNode. There's nothing obviously wrong with the code you've shown us; if you're having problems please provide a minimal reproducible example demonstrating the issue. - Slaw
@Slaw: Damn you're right, I probably messed up the imports. Embarassing. Anyway, thanks for your help! - Don Joe

1 Answers

0
votes

Slaw's comment: javafx.scene.control.ScrollPane definitely is a javafx.scene.Node. The class hierarchy is: ScrollPane → Control → Region → Parent → Node