Javafx:SplitPane 调整子项大小
Javafx : SplitPane resize children
我最喜欢一个 .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>
我错过了什么,或者为什么我无法调整窗格?
将 ScrollPane 的 fitToHeight 和 fitToWidth 属性设置为 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">
我最喜欢一个 .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>
我错过了什么,或者为什么我无法调整窗格?
将 ScrollPane 的 fitToHeight 和 fitToWidth 属性设置为 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">