Child components of containers like VBox/HBox take up space even when visible is set to false. How do I prevent this?
Set the includeInLayout property also to false
When a component’s visible property is set to false, it is just hidden from the user. Parent container still considers the component while computing the layout and renders the component along with other child components. If you want to hide a component from the user and also make sure it is not included in the layout, set the includeInLayout property to false.