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.
To hide a button in JavaFX, setVisible(false) should be invoked on the button object to remove it from view. The button will still maintain its position and other nodes may still be arranged around it. To uncouple the button from the layout's position calculations, developers can additionally setManaged(false) .
You just need to call projectList. getChildren(). remove(button); in the button's handler method. (As an aside, you should really use setOnAction , not setOnMouseClicked .)
The JavaFX HBox component is a layout component which positions all its child nodes (components) in a horizontal row. The Java HBox component is represented by the class javafx. scene.
Before calling legendPane.setVisible, call:
legendPane.managedProperty().bind(legendPane.visibleProperty());
The Node.managed property prevents a node in a Scene from affecting the layout of other scene nodes.
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