gpt4 book ai didi

JavaFx:自动调整 TitledPane 大小

转载 作者:行者123 更新时间:2023-12-02 02:29:18 28 4
gpt4 key购买 nike

我有一个 View ,其中 SplitPane 中有两个垂直方向的 TitledPane。我希望当我折叠其中一个时,将另一个的大小调整为场景的高度。这是我的 .fxml 文件的代码:

<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TableColumn?>
<BorderPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:id="pane"
fx:controller="stackoverflow.three.Controller">
<center>
<SplitPane fx:id="split" orientation="VERTICAL">
<TitledPane fx:id="first" text="First">
<TableView>
<columns>
<TableColumn text="Test"/>
</columns>
</TableView>
</TitledPane>
<TitledPane fx:id="second" text="Second">
<TableView>
<columns>
<TableColumn text="Test"/>
</columns>
</TableView>
</TitledPane>
</SplitPane>
</center>
</BorderPane>

以下是一些截图:初始状态: Initial State当第一个折叠时: First collapsed

正如您所看到的,如果我折叠第一个 View , View 底部会有一个间隙,但我不想要这个间隙。

我尝试将 maxHeight 设置为无限,但随后自动移动到第一个位置不起作用...知道我能做什么吗?

最佳答案

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TableColumn?>

<BorderPane fx:id="pane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="stackoverflow.three.Controller">
<center>
<VBox prefHeight="800.0">
<children>
<TitledPane fx:id="first" text="First">
<content>
<TableView prefHeight="2000.0">
<columns>
<TableColumn text="Test" />
</columns>
</TableView>
</content>
</TitledPane>
<TitledPane fx:id="second" text="Second">
<content>
<TableView prefHeight="2000.0">
<columns>
<TableColumn text="Test" />
</columns>
</TableView>
</content>
</TitledPane>
</children>
</VBox>
</center>
</BorderPane>

关于JavaFx:自动调整 TitledPane 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47413305/

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