我有一个以BorderPane
为主要容器的程序。在此BorderPane
的中心是ScrollPane
,其中包含动态GridPane
。
我希望能够显示包含更多行的大型GridPanes,因此我将GridPane
包装在ScrollPane
中。 (我使用了场景构建器)
滚动条不起作用。我尝试更改HMax
和VMax
属性,但向上或向下滚动时没有任何反应。
接下来,我尝试在生成新的动态GridPane后使用myScrollPane.setContent(myDynamicGridpane)
重置内容。
我想通过向上和向下滚动来查看完整的动态GridPane。
由Scene Builder生成的FXML部分:
<ScrollPane fx:id="contentScrollPane" fitToHeight="true" fitToWidth="true" hbarPolicy="ALWAYS" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" nodeOrientation="LEFT_TO_RIGHT" prefHeight="291.0" prefWidth="422.0" vbarPolicy="ALWAYS" BorderPane.alignment="TOP_LEFT">
<content>
<GridPane fx:id="dynamicPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="126.0" prefWidth="277.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="150.0" minWidth="150.0" prefWidth="150.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="100.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
</GridPane>
</content>
</ScrollPane>