gpt4 book ai didi

JavaFX : SplitPane resize children

转载 作者:行者123 更新时间:2023-11-30 06:41:21 25 4
gpt4 key购买 nike

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

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

我错过了什么,或者为什么我无法调整 Pane 大小?

最佳答案

将 ScrollPane 的 fitToHeightfitToWidth 属性设置为 true:

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

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 resize children,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44329829/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com