1

我在 JavaFX 中制作了一个应用程序。我使用 Scene Builder,但我的 GridPane 有问题。你能告诉我为什么我的 GridPane 没有向右增长吗?

这是我的应用程序的屏幕。 我的应用程序的屏幕

和 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>
4

1 回答 1

0

在场景构建器中,您可以对窗格说“适合父母”。你试过了吗?您还可以检查场景构建器中的布局设置,设置了哪些锚窗格约束。

于 2016-04-21T12:12:40.727 回答