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 Button
s 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. :)
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.
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.
VBox
supports spacing:
VBox menuButtons = new VBox(5);
or
menuButtons.setSpacing(5);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With