我的屏幕上有一个滚动 Pane ,里面有一个垂直框。我在此 vbox 中添加了许多复选框(并且我看到它在扩展),但滚动 Pane 似乎不知道当内容超过该 Pane 的高度时它应该开始显示滚动条。我已经尝试更改滚动条策略,但它只显示滚动条,我实际上无法滚动。我该如何解决这个问题?
private void addCheckbox(String checkbox){
CheckBox c = new CheckBox(checkbox);
c.setPadding(this.paddingCheckBoxes);
c.setSelected(true);
this.vBoxFilters.getChildren().add(c);
}
这是 fxml:
<StackPane>
<children>
<ScrollPane fx:id="scrollPaneFilters" prefHeight="878.0" prefWidth="260.0">
<content>
<VBox fx:id="vBoxFilters" minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0" />
</content>
</ScrollPane>
</children>
</StackPane>
最佳答案
尝试在 fxml 中删除 VBox 的 prefHeight
关于JavaFX ScrollPane 不随 VBox 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36579609/