gpt4 book ai didi

JavaFX HBox 隐藏项目

转载 作者:IT老高 更新时间:2023-10-28 21:10:12 26 4
gpt4 key购买 nike

如何在 HBox 中隐藏一个项目,并让该项目使用的空间可供其他项目使用。

TitledPane legendPane = new TitledPane("Legend", _legend);
legendPane.setVisible(false);
LineChart chart = new LineChart<Number, Number>(_xAxis, _yAxis);

HBox hbox = new HBox(5);
hbox.getChildren().addAll(legendPane, chart);

在上面的代码中,我希望图表节点在隐藏图例 Pane 时使用所有可用空间。

最佳答案

在调用 legendPane.setVisible 之前,调用:

legendPane.managedProperty().bind(legendPane.visibleProperty());

Node.managed属性防止场景中的节点影响其他场景节点的布局。

关于JavaFX HBox 隐藏项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12200195/

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