title: javafx automatic resizing and button padding
body: <p>I'm trying to make an on screen keyboard with Javafx for the layout. I'm using the Scene Builder to make the FXML file.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import java.lang.*?&gt;
  &lt;?import java.util.*?&gt;
  &lt;?import javafx.geometry.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import javafx.scene.paint.*?&gt;
  &lt;?import javafx.scene.text.*?&gt;
  
  &lt;AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="186.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2"&gt;
    &lt;children&gt;
      &lt;VBox layoutX="0.0" layoutY="0.0" prefHeight="186.0" prefWidth="600.0" rotate="0.0" spacing="2.0"&gt;
        &lt;children&gt;
          &lt;HBox minHeight="33.0" prefHeight="33.0" prefWidth="600.0" spacing="2.0"&gt;
            &lt;children&gt;
              &lt;Label maxWidth="-Infinity" prefHeight="33.0" prefWidth="35.0" text="Milk" textAlignment="CENTER" /&gt;
              &lt;Label maxWidth="-Infinity" prefHeight="33.0" text="Mister" /&gt;
              &lt;Label maxWidth="-Infinity" prefHeight="35.0" text="Minimum" /&gt;
            &lt;/children&gt;
            &lt;padding&gt;
              &lt;Insets left="5.0" /&gt;
            &lt;/padding&gt;
          &lt;/HBox&gt;
          &lt;HBox prefHeight="29.0" prefWidth="600.0"&gt;
            &lt;children&gt;
              &lt;Button minWidth="29.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="29.0" text="Esc" textAlignment="CENTER" underline="false"&gt;
                &lt;font&gt;
                  &lt;Font size="9.0" /&gt;
                &lt;/font&gt;
              &lt;/Button&gt;
              &lt;Button mnemonicParsing="false" text="`" textAlignment="CENTER" /&gt;
              &lt;Button mnemonicParsing="false" text="1" /&gt;
              &lt;Button mnemonicParsing="false" text="2" /&gt;
              &lt;Button mnemonicParsing="false" text="3" /&gt;
              &lt;Button mnemonicParsing="false" text="4" /&gt;
              &lt;Button mnemonicParsing="false" text="5" /&gt;
              &lt;Button mnemonicParsing="false" text="6" /&gt;
              &lt;Button mnemonicParsing="false" text="7" /&gt;
              &lt;Button mnemonicParsing="false" text="9" /&gt;
              &lt;Button mnemonicParsing="false" text="0" /&gt;
              &lt;Button mnemonicParsing="false" text="-" /&gt;
              &lt;Button mnemonicParsing="false" text="=" /&gt;
              &lt;Button mnemonicParsing="false" text="Backspace" /&gt;
            &lt;/children&gt;
          &lt;/HBox&gt;
          &lt;HBox prefHeight="57.0" prefWidth="600.0"&gt;
            &lt;children&gt;
              &lt;VBox minHeight="50.0" prefHeight="78.0" prefWidth="505.0" HBox.hgrow="ALWAYS"&gt;
                &lt;children&gt;
                  &lt;HBox prefHeight="29.0" prefWidth="-1.0"&gt;
                    &lt;children&gt;
                      &lt;Button mnemonicParsing="false" prefHeight="27.0" text="Tab" /&gt;
                      &lt;Button mnemonicParsing="false" text="q" /&gt;
                      &lt;Button mnemonicParsing="false" text="w" /&gt;
                      &lt;Button mnemonicParsing="false" text="e" /&gt;
                      &lt;Button mnemonicParsing="false" text="r" /&gt;
                      &lt;Button mnemonicParsing="false" text="t" /&gt;
                      &lt;Button mnemonicParsing="false" text="y" /&gt;
                      &lt;Button mnemonicParsing="false" text="u" /&gt;
                      &lt;Button mnemonicParsing="false" text="i" /&gt;
                      &lt;Button mnemonicParsing="false" text="o" /&gt;
                      &lt;Button mnemonicParsing="false" text="p" /&gt;
                      &lt;Button mnemonicParsing="false" text="[" /&gt;
                      &lt;Button mnemonicParsing="false" text="]" /&gt;
                    &lt;/children&gt;
                  &lt;/HBox&gt;
                  &lt;HBox minHeight="-1.0" prefHeight="28.0" prefWidth="-1.0"&gt;
                    &lt;children&gt;
                      &lt;Button mnemonicParsing="false" prefWidth="71.0" text="Caps" /&gt;
                      &lt;Button mnemonicParsing="false" text="a" /&gt;
                      &lt;Button mnemonicParsing="false" text="s" /&gt;
                      &lt;Button mnemonicParsing="false" text="d" /&gt;
                      &lt;Button mnemonicParsing="false" text="f" /&gt;
                      &lt;Button mnemonicParsing="false" text="g" /&gt;
                      &lt;Button mnemonicParsing="false" text="h" /&gt;
                      &lt;Button mnemonicParsing="false" text="j" /&gt;
                      &lt;Button mnemonicParsing="false" text="k" /&gt;
                      &lt;Button mnemonicParsing="false" text="l" /&gt;
                      &lt;Button mnemonicParsing="false" text=";" /&gt;
                      &lt;Button mnemonicParsing="false" text="'" /&gt;
                      &lt;Button mnemonicParsing="false" text="\\" /&gt;
                    &lt;/children&gt;
                  &lt;/HBox&gt;
                &lt;/children&gt;
              &lt;/VBox&gt;
              &lt;Button mnemonicParsing="false" prefHeight="57.0" prefWidth="132.0" text="Enter" /&gt;
            &lt;/children&gt;
          &lt;/HBox&gt;
          &lt;HBox prefHeight="27.000099999997474" prefWidth="600.0"&gt;
            &lt;children&gt;
              &lt;Button mnemonicParsing="false" prefWidth="85.0" text="Shift" /&gt;
              &lt;Button mnemonicParsing="false" text="z" /&gt;
              &lt;Button mnemonicParsing="false" text="x" /&gt;
              &lt;Button mnemonicParsing="false" text="c" /&gt;
              &lt;Button mnemonicParsing="false" text="v" /&gt;
              &lt;Button mnemonicParsing="false" text="b" /&gt;
              &lt;Button mnemonicParsing="false" text="n" /&gt;
              &lt;Button mnemonicParsing="false" text="m" /&gt;
              &lt;Button mnemonicParsing="false" text="," /&gt;
              &lt;Button mnemonicParsing="false" text="." /&gt;
              &lt;Button mnemonicParsing="false" text="/" /&gt;
              &lt;Button mnemonicParsing="false" text="^" /&gt;
              &lt;Button mnemonicParsing="false" prefWidth="56.0" text="Shift" /&gt;
              &lt;Button mnemonicParsing="false" text="Del" /&gt;
            &lt;/children&gt;
          &lt;/HBox&gt;
          &lt;HBox prefHeight="29.0" prefWidth="600.0" VBox.vgrow="ALWAYS"&gt;
            &lt;children&gt;
              &lt;Button mnemonicParsing="false" text="Fn" /&gt;
              &lt;Button mnemonicParsing="false" text="Ctrl"&gt;
                &lt;HBox.margin&gt;
                  &lt;Insets /&gt;
                &lt;/HBox.margin&gt;
              &lt;/Button&gt;
              &lt;Button mnemonicParsing="false" text="Win" /&gt;
              &lt;Button mnemonicParsing="false" text="Alt" /&gt;
              &lt;Button mnemonicParsing="false" prefWidth="105.0" text="Space" HBox.hgrow="ALWAYS" /&gt;
              &lt;Button mnemonicParsing="false" text="Alt" /&gt;
              &lt;Button mnemonicParsing="false" prefWidth="-1.0" text="Ctrl" textAlignment="LEFT" /&gt;
              &lt;Button mnemonicParsing="false" text="&amp;lt;" /&gt;
              &lt;Button mnemonicParsing="false" text="v" /&gt;
              &lt;Button mnemonicParsing="false" text="&amp;gt;" /&gt;
              &lt;Button mnemonicParsing="false" text="Menu" /&gt;
            &lt;/children&gt;
          &lt;/HBox&gt;
        &lt;/children&gt;
      &lt;/VBox&gt;
    &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>Which looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/ZeOyS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZeOyS.png" alt="enter image description here"></a></p>
  
  <p>But when the window is resized, the contents don't. I want the buttons to gain/lose size until it fits the window. Turning on Hgrow and Vgrow didn't work.</p>
  
  <p>And I can't find how to set the padding on buttons. I want to make buttons like Ctrl smaller without losing the text.</p>