title: JavaFX: keep all components in center even when resizing a window
body: <p>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.</p>
  
  <p>Please see the picture here: <a href="http://postimg.org/image/r42kvvfbf/" rel="noreferrer">http://postimg.org/image/r42kvvfbf/</a></p>
  
  <p>FXML file:</p>
  
  <pre><code>&lt;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"&gt;
    &lt;children&gt;
      &lt;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"&gt;
        &lt;children&gt;
          &lt;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"&gt;
            &lt;children&gt;
              &lt;Label text="ID number" /&gt;
              &lt;TextField fx:id="id" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="210.0" promptText="" /&gt;
              &lt;Label text="Password" /&gt;
              &lt;TextField fx:id="password" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="210.0" promptText="" /&gt;
              &lt;HBox id="HBox" alignment="CENTER" spacing="5.0"&gt;
                &lt;children&gt;
                  &lt;Button mnemonicParsing="false" onAction="#loginAction" text="Вход" textAlignment="CENTER" textOverrun="ELLIPSIS" /&gt;
                &lt;/children&gt;
              &lt;/HBox&gt;
            &lt;/children&gt;
            &lt;padding&gt;
              &lt;Insets bottom="20.0" left="20.0" right="20.0" top="20.0" /&gt;
            &lt;/padding&gt;
          &lt;/VBox&gt;
        &lt;/children&gt;
        &lt;columnConstraints&gt;
          &lt;ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /&gt;
        &lt;/columnConstraints&gt;
        &lt;rowConstraints&gt;
          &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
        &lt;/rowConstraints&gt;
      &lt;/GridPane&gt;
    &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>I have tried using StackPane and only with VBox as well, but I can't achieve what I want.
  Please help!</p>