Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to remove all the contents in vBox in JavaFx?

Tags:

javafx

I'm trying to do the a Javafx project. And I have some problem with it. I have a list of text (labels) placed inside the vBox. Is there a way to remove all the text in the vBox? For example, when I click a button "Remove", everything inside the vBox will be disappeared. Is it possible to do that?

like image 373
Yin Avatar asked Mar 08 '15 10:03

Yin


People also ask

What is the difference between VBox and HBox?

HBox – arranges its content nodes horizontally in a single row. VBox – arranges its content nodes vertically in a single column.

How does VBox work JavaFX?

VBox is a part of JavaFX. VBox lays out its children in form of vertical columns. If the vbox has a border and/or padding set, then the contents will be layed out within those insets. VBox class extends Pane class.

What is VBox and HBox in JavaFX?

The layout panes HBox and VBox are definitely the most basic layout containers in JavaFX 2.0. As you can already tell by their name, their purpose is to layout all their children in one horizontal row ( HBox ) or in one vertical column ( VBox ).


2 Answers

Oh! I just figured it out. I can use vBox.getChildren().clear(); It works!

like image 141
Yin Avatar answered Oct 10 '22 05:10

Yin


vBox.getChildren().removeAll(vBox.getChildren());

works too

like image 36
B15 Avatar answered Oct 10 '22 06:10

B15