Reputation: 11801
How can I acheive an evenly split UI, as the Player boxes demonstrate in the following example:
I would model it as an HBox with 2 evenly sized VBoxes, but I can't get them to stretch to the same size in the HBox.
Upvotes: 3
Views: 3626
Reputation: 1999
Stretching VBoxes as two halves of single HBox works for me with HBox.hgrow="ALWAYS"
property set for both VBoxes:
<HBox>
<VBox HBox.hgrow="ALWAYS">
...
</VBox>
<VBox HBox.hgrow="ALWAYS">
...
</VBox>
</HBox>
Upvotes: 2
Reputation: 932
Give your HBox a PrefWidth Value. Then you can bind the Widths of your VBoxes to the half of that Width
hBox.setPrefWidth(400);
vbox.setPrefWidth(hbox.getPrefWidth()/2);
You might wanna take a look at JavaFX Scene Builder. There you can Design your Layouts. Just saw using a SplitPane would also work. There you can set the DividerPosition to 0.5 (so centered). Then you can put every kind of Panes inside you like.
Upvotes: 0