JavaFX - setVisible hides the element but doesn't rearrange adjacent nodes

fxml, java, javafx, javafx-2, javafx-8

Solution

`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());`

Problem

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.

Original source

Related problems