JAVAFX How to center Vbox in right section of BorderPane

410 Views Asked by At

I have a problem with putting my VBox with 3 buttons in the center of the right section of BorderPane. Is there a way to do it in FXML or CSS?

UPDATE:

This is code in FXML

 <right>
        <VBox id="otherButtons_vbox">
            <Button text="Add automobile"
                    fx:id="addAutomobileButton" onAction="#createAddAutomobileBox"
                    id="other_buttons"/>
            <Button text="Update automobile"
                    fx:id="updateAutomobileButton" onAction="#UpdateAutomobileBox"
                    id="other_buttons"/>
            <Button text="Delete automobile"
                    fx:id="deleteAutomobileButton" onAction="#DeleteAutomobileBox"
                    id="other_buttons"/>
        </VBox>

    </right>

this is the CSS file

#otherButtons_vbox {
            -fx-background-color: black;
            -fx-border-color: red;
            -fx-alignment: center-right;
            -fx-spacing: 10;
            -fx-padding: 10 10 10 10;
            -fx-pref-width: 170;
            -fx-max-height: 190;
}

And the Screenshot of the APP. I want the Vbox to be in the center of right section of BorderPate. Thank you very much for the reply!

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

You can do this from the fxml. Set the BorderPane.alignment attribute for the VBox:

...
<VBox id="otherButtons_vbox" BorderPane.alignment="CENTER">
...