Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX HBox hide item

Tags:

java

javafx-2

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.

like image 996
José Avatar asked Aug 30 '12 15:08

José


People also ask

How to hide an element in JavaFX?

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) .

How to delete a button in JavaFX?

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 .)

What is HBox in JavaFX?

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.


1 Answers

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.

like image 90
jewelsea Avatar answered Oct 04 '22 20:10

jewelsea