JavaFX:SplitPane调整子级大小 [英] Javafx : SplitPane resize children

查看:145
本文介绍了JavaFX:SplitPane调整子级大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收藏了一个.fxml文件,在其中添加了一些TitledPane,但是无法在应用程序中调整它们的大小.这是代码:

I fave an .fxml file, in which I have added some TitledPane but I cannot resize them in the application. Here is the code:

<ScrollPane AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.bottomAnchor="0.0"
            AnchorPane.leftAnchor="0.0">
    <SplitPane orientation="VERTICAL" fx:id="splitPane">
        <TitledPane>
            <TextArea fx:id="taTop" wrapText="true" editable="false" prefHeight="100"/>
        </TitledPane>
        <TitledPane>
            <TableView fx:id="tableFrist" minHeight="120" maxHeight="120">
                <columns>
                    <TableColumn fx:id="column" prefWidth="200"/>
                </columns>
            </TableView>
        </TitledPane>
        <TitledPane>
            <TreeTableView fx:id="tableSecond">
                <columns>
                    <TreeTableColumn fx:id="columnTreeS" prefWidth="200"/>
                </columns>
            </TreeTableView>
        </TitledPane>
        <TitledPane>
            <TreeTableView fx:id="tableThird">
                <columns>
                    <TreeTableColumn fx:id="columnTreeT" prefWidth="200"/>
                </columns>
            </TreeTableView>
        </TitledPane>
        <TitledPane>
            <TextArea fx:id="taBot" wrapText="true" editable="false"/>
        </TitledPane>
    </SplitPane>
</ScrollPane>

我想念什么,或者为什么我不能调整窗格的大小?

What did I miss, or why I cannot resise the panes?

推荐答案

将ScrollPane的 fitToHeight fitToWidth 属性设置为true:

Set the fitToHeight and fitToWidth attributes to true for ScrollPane:

https://docs .oracle.com/javase/8/javafx/api/javafx/scene/control/ScrollPane.html#fitToHeightProperty

如果为true且所包含的节点为可调整大小",则将调整该节点的大小以匹配ScrollPane视口的高度.如果所包含的节点不是可调整大小"的节点,则将忽略此值.

If true and if the contained node is a Resizable, then the node will be kept resized to match the height of the ScrollPane's viewport. If the contained node is not a Resizable, this value is ignored.

更改

<ScrollPane AnchorPane.topAnchor="0.0" 
            AnchorPane.rightAnchor="0.0" 
            AnchorPane.bottomAnchor="0.0"
            AnchorPane.leftAnchor="0.0">

<ScrollPane AnchorPane.topAnchor="0.0" 
            AnchorPane.rightAnchor="0.0" 
            AnchorPane.bottomAnchor="0.0"
            AnchorPane.leftAnchor="0.0" 
            fitToHeight="true" 
            fitToWidth="true">

这篇关于JavaFX:SplitPane调整子级大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆