I have a JavaFX ButtonBar
with two Buttons (created via SceneBuilder).
I want one of the buttons to be left-aligned and the other right-aligned. (see screenshot)
From the docs I already know how I could achieve this inside the java-source-code:
ButtonBar.setButtonData(newButton, ButtonData.LEFT);
I want to know how to achieve this WITHOUT having to write this inside my java-files but
how I can achieve this using just SceneBuilder or the corresponding fxml file.
My .fxml file currently looks like this:
<ButtonBar>
<buttons>
<Button text="New" />
<Button text="Save" />
</buttons>
</ButtonBar>
* I'm on Windows
** This answer is not what I want, because he is using a ToolBar, but I want to know how to do this with a ButtonBar (and his approach does not work for the ButtonBar)
After some Trial and Error I found at least a way to do it directly via the .fxml-file:
You can assign the Button elements with ButtonBar.buttonData
attributes and then assign a value to them.
<ButtonBar>
<buttons>
<Button text="New" ButtonBar.buttonData="LEFT" />
<Button text="Save" ButtonBar.buttonData="RIGHT" />
</buttons>
</ButtonBar>
The docs for the ButtonBar.ButtonData enum are pretty straighforward. So I found the solution to my problem with the "LEFT" and "RIGHT" enum values.
If anyone knows/finds out how to do this directly in SceneBuilder, I would be grateful!