有没有办法设置列数和行数的GridPane数量?
我目前有这样的东西:
<fx:root type="GridPane" xmlns:fx="http://javafx.com/fxml"
stylesheets="view/Style.css"
maxHeight="Infinity" maxWidth="Infinity">
<gridLinesVisible>true</gridLinesVisible>
<children>
<Pane fx:id="center"
GridPane.columnIndex="1" GridPane.rowIndex="1"
GridPane.columnSpan="5" GridPane.rowSpan="3"
GridPane.hgrow="always" GridPane.vgrow="always"/>
<Pane fx:id="options"
GridPane.columnIndex="0" GridPane.rowIndex="5"
GridPane.columnSpan="6"/>
</children>
</fx:root>我会动态地向其中添加元素。
问题来了,如果行/列没有任何元素,它会被擦除,因此窗格的外观很奇怪(就像在(3,0)中添加元素,然后在(2,X),(1,X)上添加元素,因为(4,X)和(5,X)上没有元素,所以(3,0)上的元素不会在窗格中居中)
发布于 2013-03-15 19:16:12
使用独立HBox和VBox
HBox HB = new HBox();
HB.getChildren().addAll(btnexample1, btnexample2);
GridPane.setHalignment(HB, HPos.LEFT);
HB.setSpacing(5);
grid.add(HB, 0, 8);发布于 2015-07-16 05:49:10
你说它发生在没有元素的时候。只需始终拥有一个元素,但使其包含空白数据。like Label.text = "";
https://stackoverflow.com/questions/15429784
复制相似问题