JavaFX HBox隐藏项目 [英] JavaFX HBox hide item
本文介绍了JavaFX HBox隐藏项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在HBox中隐藏某个项目,并将此项目使用的空间提供给其他项目。
How can i hide an item in HBox, and made space used by this item available to other items.
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);
在上面的代码中,我希望图表节点在隐藏图例窗格时使用所有可用空间。
In the above code i want the chart node to use all available space when the legend pane is hidden.
推荐答案
在调用legendPane.setVisible之前,请致电:
Before calling legendPane.setVisible, call:
legendPane.managedProperty().bind(legendPane.visibleProperty());
Node.managed 属性可防止场景中的节点影响其他场景节点的布局。
The Node.managed property prevents a node in a Scene from affecting the layout of other scene nodes.
这篇关于JavaFX HBox隐藏项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文