Javafx 2 GridPane:行限制百分比高度未按预期工作

Javafx 2 GridPane:行限制百分比高度未按预期工作,javafx-2,javafx,fxml,Javafx 2,Javafx,Fxml,如果网格窗格有两行两列,则将行约束设置为50%的高度会导致不必要的行为 代码: (底部提到的属性) 我希望这两排人能以50%的比例分享他们的可用高度。他们这样做,但他们也消耗了比需要更多的空间 指定和未指定百分比高度的结果图片: 我是否理解percentHeight错误,或者有其他方法吗?可能与以下内容有关:JavaFX CSS参考页面上有评论说percentage属性不适用于每个元素。你可以看看这个帖子: <BorderPane xmlns:fx="http://javafx.co

如果网格窗格有两行两列,则将行约束设置为50%的高度会导致不必要的行为

代码:


(底部提到的属性)

我希望这两排人能以50%的比例分享他们的可用高度。他们这样做,但他们也消耗了比需要更多的空间

指定和未指定
百分比高度的结果图片:


我是否理解
percentHeight
错误,或者有其他方法吗?

可能与以下内容有关:JavaFX CSS参考页面上有评论说percentage属性不适用于每个元素。你可以看看这个帖子:
<BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="..." stylesheets="@general.css" prefWidth="800" prefHeight="600">
    <top>
        <VBox>
            <!-- ... -->
        </VBox>
    </top>

    <bottom>
        <HBox>
            <!-- ... -->
        </HBox>
    </bottom>

    <center>
        <GridPane > 
            <children>

                <ScrollPane fx:id="tilePane" GridPane.columnIndex="0" GridPane.rowIndex="0">
                    <content>
                    </content>
                    <GridPane.margin>
                        <Insets bottom="2" left="2" right="2" top="2" />
                    </GridPane.margin>
                </ScrollPane>

                <TreeView fx:id="listPane" GridPane.columnIndex="0" GridPane.rowIndex="1">
                    <root>
                        <TreeItem value="Stages" />
                    </root>
                    <GridPane.margin>
                        <Insets bottom="2" left="2" right="2" top="2" />
                    </GridPane.margin>
                </TreeView>

                <ScrollPane fx:id="mapPane" GridPane.columnIndex="1" GridPane.rowIndex="0" GridPane.rowSpan="2">
                    <content>
                    </content>
                    <GridPane.margin>
                        <Insets bottom="2" left="2" right="2" top="2" />
                    </GridPane.margin>
                </ScrollPane>

            </children>

            <columnConstraints>
                <ColumnConstraints hgrow="ALWAYS" percentWidth="25"/>
                <ColumnConstraints hgrow="ALWAYS" />
            </columnConstraints>

            <rowConstraints>
                <RowConstraints vgrow="ALWAYS" percentHeight="50" />
                <RowConstraints vgrow="ALWAYS" percentHeight="50" />
            </rowConstraints>
        </GridPane>
    </center>
</BorderPane>