Adding space between buttons in VBox

codepleb picture codepleb · Aug 21, 2013 · Viewed 82.8k times · Source

I have a collection of buttons:

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

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

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

I'm glad for any ideas. :)

Answer

Sergey Grinev picture Sergey Grinev · Aug 21, 2013

VBox supports spacing:

VBox menuButtons = new VBox(5);

or

menuButtons.setSpacing(5);