Reputation: 157
I new to javaFx and using fxml to create templates.
I can't manage to center a Vbox
in a Pane
that is too big, although I'm certain it must be quite straightforward.
I also want a border around the VBox
.
Can anyone help? Here is what I have:
<TitledPane text="Title" collapsible="false">
<content>
<GridPane hgap="10" vgap="10">
<children>
<VBox alignment="TOP_CENTER" spacing="10">
<!-- Content -->
</VBox>
</children>
<columnConstraints>
<ColumnConstraints halignment="CENTER"/>
</columnConstraints>
<rowConstraints>
<RowConstraints/>
</rowConstraints>
</GridPane>
</content>
</TitledPane>
I guess the GridPane
is a bad idea, but this is the way I know to have the borders as I want them.
Thanks for your time!
Upvotes: 0
Views: 736
Reputation: 82461
I guess the
GridPane
is a bad idea, but this is the way I know to have the borders as I want them.
Yes it is. Using a GridPane
for a single child is a overkill. Simply use a StackPane
with a padding
of 10
:
<TitledPane text="Title" collapsible="false">
<content>
<StackPane>
<padding>
<Insets topRightBottomLeft="10"/>
</padding>
<children>
<VBox alignment="TOP_CENTER" spacing="10">
<children>
<!-- Content -->
</children>
</VBox>
</children>
</StackPane>
</content>
</TitledPane>
Upvotes: 1