title: JavaFX How to change the GridPane row height programmatically
body: <p>I have a problem that has been driving me nuts for a couple of days.</p>
  
  <p>I have a GridPane and I want to hide the first row when I click on a button.
  <br>This is the FXML file
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;VBox prefHeight="200.0" prefWidth="100.0"&gt;
  &lt;children&gt;
   &lt;Button fx:id="buttonTest" mnemonicParsing="false" onAction="#handleButtonTestAction" text="Button" /&gt;
  &lt;GridPane fx:id="gridPaneTest" gridLinesVisible="true" layoutX="0.5" layoutY="0.5" BorderPane.alignment="CENTER"&gt;
    &lt;columnConstraints&gt;
      &lt;ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /&gt;
      &lt;ColumnConstraints 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 minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
      &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
    &lt;/rowConstraints&gt;
    &lt;children&gt;
     &lt;Label fx:id="labelTopLeft" text="top left"&gt;
      &lt;font&gt;
       &lt;Font size="15.0" /&gt;
      &lt;/font&gt;
     &lt;/Label&gt;
     &lt;Label fx:id="labelTopRight" text="top right" GridPane.columnIndex="1"&gt;
      &lt;font&gt;
       &lt;Font size="15.0" /&gt;
      &lt;/font&gt;
     &lt;/Label&gt;
     &lt;Label text="center left" GridPane.rowIndex="1"&gt;
      &lt;font&gt;
       &lt;Font size="15.0" /&gt;
      &lt;/font&gt;
     &lt;/Label&gt;
     &lt;Label text="center right" GridPane.columnIndex="1" GridPane.rowIndex="1"&gt;
      &lt;font&gt;
       &lt;Font size="15.0" /&gt;
      &lt;/font&gt;
     &lt;/Label&gt;
     &lt;Label text="bottom left" GridPane.rowIndex="2"&gt;
      &lt;font&gt;
       &lt;Font size="15.0" /&gt;
      &lt;/font&gt;
     &lt;/Label&gt;
     &lt;Label text="bottom right" GridPane.columnIndex="1" GridPane.rowIndex="2"&gt;
      &lt;font&gt;
       &lt;Font size="15.0" /&gt;
      &lt;/font&gt;
     &lt;/Label&gt;
    &lt;/children&gt;
   &lt;/GridPane&gt;
  &lt;/children&gt;
  &lt;/VBox&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>If I click on the Button I do this</p>
  
  <pre class="lang-java prettyprint-override"><code>@FXML
  public void handleButtonTestAction() {
  
      labelTopLeft.setVisible(false);
      labelTopRight.setVisible(false);
  
      gridPaneTest.getRowConstraints().get(0).setMinHeight(0);
      gridPaneTest.getRowConstraints().get(0).setPrefHeight(0);
      gridPaneTest.getRowConstraints().get(0).setMaxHeight(0);
  }
  </code></pre>
  
  <p>After I click the Button, the labels are invisible as expected but the height of the first row doesn't change at all.
  Do I have to update the GridPane after I change the row constraints or is there anything else to do?</p>
  
  <p>THANK YOU!</p>