Can anyone tell me is there any display:none property in JavaFX like in Css?
Actually I want to hide some labels and don't want them to occupy space when hidden.
How can I achieve this in JavaFX?
TIA
Nodes are considered for layout purposes by parents as long as their managed
property is true
. For this reason you need to set both the visible
and the managed
property:
node.setVisible(false);
node.setManaged(false);
This is an alternative to simply removing the node from it's parent that allows you to make the node reappear again. If you don't want do anything with the node after hiding it, you should simply remove it from the scene instead:
parentLayout.getChildren().remove(node);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With