簡體   English   中英

JavaFX - GridPane中的ScrollPane

[英]JavaFX - ScrollPane within GridPane

我想在我的應用程序窗口中使用ScrollPane,它不會填滿整個場景,但只占用它的一部分,因為我想在它下面放一個按鈕。

就像在這幅草圖中一樣: https//i.imgur.com/eUA7Af7.png

我嘗試使用GridPane,但我只能將Nodes作為GridPane的子節點,因為ScrollPane不是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();
}

Slaw的評論:javafx.scene.control.ScrollPane肯定是一個javafx.scene.Node。 類層次結構是:ScrollPane→控制→區域→父→節點

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM