我用JavaFX开发了一个应用程序。我使用Scene Builder,但是GridPane出现问题。
您能告诉我为什么我的GridPane不能正确显示吗?
这是我的应用程序的屏幕。
Screen of my app
和FXML文件:
<BorderPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8">
<center>
<HBox maxWidth="1.7976931348623157E308" minWidth="500.0" BorderPane.alignment="CENTER">
<children>
<Separator orientation="VERTICAL" prefHeight="200.0" HBox.hgrow="ALWAYS" />
<VBox BorderPane.alignment="CENTER" HBox.hgrow="ALWAYS">
<children>
<GridPane VBox.vgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="1.7976931348623157E308" 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 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>
<children>
<Label text="Label" />
<Label text="Label" GridPane.rowIndex="1" />
<Label text="Label" GridPane.rowIndex="2" />
<Label text="Label" GridPane.rowIndex="3" />
<Label text="Label" GridPane.rowIndex="4" />
<Label text="Label" GridPane.rowIndex="5" />
<TextArea prefHeight="85.0" prefWidth="150.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="5" GridPane.vgrow="ALWAYS" />
<TextField GridPane.columnIndex="1" />
<Label text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Label" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="Label" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Label" GridPane.columnIndex="1" GridPane.rowIndex="4" />
</children>
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin>
</GridPane>
</children>
</VBox>
</children>
</HBox>
</center>
</BorderPane>
最佳答案
在场景构建器中,您可以对窗格说“适合父母”。你试过了吗?您还可以检查场景构建器中的布局设置,设置哪些锚窗格约束。
关于java - javaFX场景构建器。 APP没有响应,无法正常运行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33545545/