如何在Gridpane中获得相同的TitledPanes垂直尺寸? (JavaFX,Scenebuilder)

时间:2016-03-25 19:32:46

标签: javafx size fxml scenebuilder gridpane

我对右TiteldPane的垂直尺寸有疑问(见下图)。两个TitledPanes都放在GridPane中。我希望较小的一个像左边那样得到相同的高度。我试图将Vgrow设置为正确的TitledPane的“总是”,但什么也没发生。此外,我试图与一个地区做一些事情没有成功。如果不给它们绝对高度,这可能吗?

提前感谢您的帮助。

enter image description here

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<AnchorPane xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <ScrollPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
        <content>
          <AnchorPane>
               <children>
                  <GridPane hgap="20.0" vgap="20.0">
                    <columnConstraints>
                      <ColumnConstraints hgrow="SOMETIMES" />
                      <ColumnConstraints hgrow="SOMETIMES" />
                    </columnConstraints>
                    <rowConstraints>
                      <RowConstraints valignment="TOP" vgrow="ALWAYS" />
                    </rowConstraints>
                     <padding>
                        <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
                     </padding>
                     <children>
                        <TitledPane animated="false" text="TitledPane">
                           <content>
                              <GridPane hgap="10.0" vgap="5.0">
                                <columnConstraints>
                                  <ColumnConstraints hgrow="SOMETIMES" minWidth="100.0" />
                                  <ColumnConstraints hgrow="SOMETIMES" minWidth="100.0" />
                                </columnConstraints>
                                <rowConstraints>
                                  <RowConstraints vgrow="SOMETIMES" />
                                  <RowConstraints vgrow="SOMETIMES" />
                                  <RowConstraints vgrow="SOMETIMES" />
                                    <RowConstraints vgrow="SOMETIMES" />
                                    <RowConstraints vgrow="SOMETIMES" />
                                    <RowConstraints vgrow="SOMETIMES" />
                                    <RowConstraints vgrow="SOMETIMES" />
                                </rowConstraints>
                                 <children>
                                    <Label text="Label" GridPane.halignment="RIGHT" />
                                    <Label GridPane.columnIndex="1" GridPane.rowIndex="1" />
                                    <Label text="Label" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
                                    <Label GridPane.columnIndex="1" GridPane.rowIndex="3" />
                                    <Label text="Label" GridPane.halignment="RIGHT" GridPane.rowIndex="4" />
                                    <Label GridPane.columnIndex="1" GridPane.rowIndex="5" />
                                    <TextField GridPane.columnIndex="1" />
                                    <TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
                                    <TextField fx:id="abgar10TF" GridPane.columnIndex="1" GridPane.rowIndex="4" />
                                 </children>
                              </GridPane>
                           </content>
                        </TitledPane>
                        <TitledPane animated="false" text="TitledPane" GridPane.columnIndex="1" GridPane.valignment="TOP" GridPane.vgrow="ALWAYS">
                           <content>
                              <GridPane hgap="10.0" vgap="5.0">
                                <columnConstraints>
                                  <ColumnConstraints hgrow="SOMETIMES" minWidth="100.0" />
                                  <ColumnConstraints hgrow="SOMETIMES" minWidth="100.0" />
                                </columnConstraints>
                                <rowConstraints>
                                  <RowConstraints vgrow="SOMETIMES" />
                                  <RowConstraints vgrow="SOMETIMES" />
                                  <RowConstraints vgrow="SOMETIMES" />
                                    <RowConstraints vgrow="SOMETIMES" />
                                </rowConstraints>
                                 <children>
                                    <Label text="Label" GridPane.halignment="RIGHT" />
                                    <Label GridPane.columnIndex="1" GridPane.rowIndex="1" />
                                    <Label text="Label" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
                                    <Label GridPane.columnIndex="1" GridPane.rowIndex="3" />
                                    <TextField GridPane.columnIndex="1" />
                                    <TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
                                 </children>
                              </GridPane>
                           </content>
                        </TitledPane>
                     </children>
                  </GridPane>
               </children>
            </AnchorPane>
        </content>
      </ScrollPane>
   </children>
</AnchorPane>

1 个答案:

答案 0 :(得分:2)

您必须将两个TitlePanes的最大高度设置为MAX_VALUE