JavaFX - setVisible不会“隐藏”元素 [英] JavaFX - setVisible doesn't "hide" the element
问题描述
在JavaFX中,如果我有2 VBox
元素的场景,并且每个 VBox
有多个标签
在其中。
如果我将顶部 VBox
设置为不可见,为什么底部 VBox
没有向上移动顶部 VBox
的场景?
VBox
不可见但我希望其他对象进入其中我想用FXML加载我的控件。
Node.setVisible(boolean)
只需切换节点的可见性状态
。
要从父项布局计算中排除节点
,您还必须通过调用 Node.setManaged(false)
。
如果您想要在可见性的同时自动更新托管状态,您可以使用@jewelsea指出的绑定: node.managedProperty()。bind(node.visibleProperty());
In JavaFX, if I have a scene with 2 VBox
elements and each VBox
has multiple Label
in it.
If I set the top VBox
to invisible, why does the bottom VBox
not move up the scene where the top VBox
was ?
The VBox
is invisible but I would expect the other objects to move into its place.
I am using FXML to load my controls.
Node.setVisible(boolean)
just toggles the visibility state of a Node
.
To exclude a Node
from its parents layout calculations you additionally have to set its managed state, by calling Node.setManaged(false)
.
If you want the managed state to be updated automatically alongside the visibility, you can use a binding as @jewelsea pointed out: node.managedProperty().bind(node.visibleProperty());
这篇关于JavaFX - setVisible不会“隐藏”元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!