本文介绍了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

更改

<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调整子级大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 19:29