如何阻止 ScrollPane 面板 JavaFX

How to block a ScrollPane panel JavaFX

我有个小问题。我正在像这样使用 JavaFX 构建接口: 我想知道,我该怎么做才能阻止我在图像中指示的 ScrollPane 的那些“线”?实际上,它不能调整大小,但在其属性中,ScrollPane 不允许我检查 属性:

我该怎么做才能解决? 提前感谢大家!

我认为你的问题是你没有为你的 ScrollPanes 添加最小值这是一个例子:

    SplitPane split = new SplitPane();
    split.setPrefSize(400, 400); 

    //First ScrollPane
    ScrollPane spA = new ScrollPane();
    spA.setMinWidth(100);  //Block the scrollPane width to 100
    spA.setFitToHeight(true);
    spA.setFitToWidth(true); 
    Pane paneA = new Pane();
    paneA.setStyle("-fx-background-color:red;");
    spA.setContent(paneA);

    //Second ScrollPane
    ScrollPane spB = new ScrollPane();
    spB.setMinWidth(100); //Block the scrollPane width to 100
    spB.setFitToHeight(true);
    spB.setFitToWidth(true); 
    Pane paneB = new Pane();
    paneB.setStyle("-fx-background-color:blue;");
    spB.setContent(paneB);

    split.getItems().addAll(spA,spB);

为了能够在你的 scrollPane 增长时使用它,你可以使用绑定并将你的 ScrollPane 的内容(width/height 属性)绑定到它们的父级(ScrollPane)示例:

//set the (FitToHeight/FitToWidth) properties to false before !
spA.widthProperty().addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {

            paneB.setMinWidth((double)newValue);
        }
    });

祝你好运!