Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding space between buttons in VBox

I have a collection of buttons:

VBox menuButtons = new VBox(); menuButtons.getChildren().addAll(addButton, editButton, exitButton); 

I want to add some spacing between these buttons, without using a CSS style sheet. I think there should be a way to do this.

setPadding(); is for the Buttons in the VBox.
setMargin(); should be for the VBox itself. But I didn't find a way for the spacing between the buttons.

I'm glad for any ideas. :)

like image 870
codepleb Avatar asked Aug 21 '13 17:08

codepleb


People also ask

How do I add a space in JavaFX?

As others have mentioned you can use setSpacing() . However, you can also use setMargin() , it is not for the pane (or box in your words), it is for individual Node s. setPadding() method is for the pane itself.

Can you put an HBox in a VBox?

The line HBox hbox = new HBox(50); therefore creates a HBox to hold three VBoxes with a gap of 50 pixel between each of them.


1 Answers

VBox supports spacing:

VBox menuButtons = new VBox(5); 

or

menuButtons.setSpacing(5); 
like image 120
Sergey Grinev Avatar answered Oct 17 '22 04:10

Sergey Grinev