Reputation: 2113
I have control that extends HBox
called TablePagination
that I created purely in code that I want to include in a FXML file, so when I do this:
<VBox fx:id="box" spacing="15" styleClass="sectionStyle">
<StackPane>
<TablePagination fx:id="pagination" StackPane.alignment="CENTER"/>
</StackPane>
</VBox>
nothing appears. But when I do it in code like this:
pagination = new TablePagination(itemTable,items);
StackPane pane = new StackPane();
pane.setAlignment(pagination, Pos.CENTER);
pane.getChildren().add(pagination);
box.getChildren().add(pane);
My control gets rendered but not in center. So what am I missing?
Upvotes: 0
Views: 50
Reputation: 2210
In your code version TablePagination
is centered within StackPane
, but nodes inside TablePagination are not. Call:
pagination.setAlignment(Pos.CENTER);
Note that StackPane.setAlignment
method is static, and you sould call:
StackPane.setAlignment(pagination, Pos.CENTER);
Upvotes: 1