Search code examples
javafx-2javafx

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


Solution

  • VBox supports spacing out of the box:

    VBox menuButtons = new VBox(5);
    

    or

    menuButtons.setSpacing(5);