You need to tell the AnchorPane
to anchor its child (the TabPane
) so that it is resized automatically when the window size changes.
If you are using Scene Builder you can achieve this by selecting the TabPane
, going to the layout section of the properties window and setting the anchor properties.
Click on each of the dotted lines until it looks like the image below.
The same effect can also be set in code using the setXXXAnchor
methods of the AnchorPane
:
pane.setLeftAnchor(tabPane, 0.0);
pane.setRightAnchor(tabPane, 0.0);
pane.setTopAnchor(tabPane, 0.0);
pane.setBottomAnchor(tabPane, 0.0);