title: Javafx how to trigger a stage layout update
body: <p>I have a very simple Javafx application, that displays a form backed by a grid. On this form I have a checkbox. When the user checks this checkbox, I want to dynamically add another row to the grid.</p>
  
  <p>From my controller:</p>
  
  <pre class="lang-java prettyprint-override"><code>checkbox.selectedProperty().addListener((obs, oldVal, newVal) - &gt; {
      if (!newVal) {
          // Add Username Label
          gridPane.add(new Label("Username : "), 0, 5);
  
          // Add Username Text Field
          gridPane.add(new TextField(), 1, 5);
      }
  });
  </code></pre>
  
  <p>The above code works just fine, the only problem is the window layout is not updated to show the new row (I mean the height is not automatically increased), unless I manually resize the window.</p>
  
  <p><strong>Question</strong> How to trigger a layout update? (I tried <code>gridPane.requestLayout()</code> but it has no effect)</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>An ugly workaround would be to hide then show the stage again.</p>