I want all my components (TextFields, labels, etc.) stay in the center with fixed size. I am making it in scene builder and it works when I see the preview, but when I launch it, components don't stay in the center when I resize it.
Please see the picture here: http://postimg.org/image/r42kvvfbf/
FXML file:
<AnchorPane id="AnchorPane" fx:id="root" maxHeight="-1.0" maxWidth="-1.0" minHeight="400.0" minWidth="600.0" prefHeight="-1.0" prefWidth="-1.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="myController">
<children>
<GridPane alignment="CENTER" prefHeight="-1.0" prefWidth="-1.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox alignment="CENTER_LEFT" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="-1.0" prefWidth="-1.0" spacing="10.0" GridPane.columnIndex="0" GridPane.rowIndex="0">
<children>
<Label text="ID number" />
<TextField fx:id="id" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="210.0" promptText="" />
<Label text="Password" />
<TextField fx:id="password" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="210.0" promptText="" />
<HBox id="HBox" alignment="CENTER" spacing="5.0">
<children>
<Button mnemonicParsing="false" onAction="#loginAction" text="Вход" textAlignment="CENTER" textOverrun="ELLIPSIS" />
</children>
</HBox>
</children>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
</VBox>
</children>
<columnConstraints>
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
I have tried using StackPane and only with VBox as well, but I can't achieve what I want. Please help!