title: Forcing layout change when Stage is resized in JavaFX
body: <p>I ran into a possible bug in JavaFX, but having short time, I am looking for a workaround.</p>
  
  <p>I have a bunch of windows containing a chart and a toolbar: </p>
  
  <pre><code>public void createGui() {
      root = new VBox();
  
      ToolBar toolbar = new ToolBar();
  
      Button btnConfig = new Button(bundle.getString("chartWindow.menu.configure"));
      btnConfig.setOnAction(e -&gt; doChartConfig());
  
      toolbar.getItems().addAll(btnConfig);
  
      chartPane = new VBox();
      root.getChildren().setAll(toolbar, chartPane);
      VBox.setVgrow(chartPane, Priority.ALWAYS);
  
      scene = new Scene(root);
      setScene(scene);
  
      updateChart();  // Creates a chart
  }
  </code></pre>
  
  <p>I have to resize them from code. (Tiling the open charts.) The simplified tiling code is:</p>
  
  <pre class="lang-java prettyprint-override"><code>// bounds is the user available area of the monitors(s)
  double windowWidth = bounds.getWidth() / tileRule.columns;
  double windowHeight = bounds.getHeight() / tileRule.rows;
  
  int r = 0;
  int c = 0;
  for (Window w : sel) {
      w.setWidth(windowWidth);
      w.setHeight(windowHeight);
      w.setX(bounds.getMinX() + c * windowWidth);
      w.setY(bounds.getMinY() + r * windowHeight);
      c++;
      if (c &gt;= tileRule.getColumns()) {
          c = 0;
          r++;
          if (r &gt;= tileRule.rows) {
              break;
          }
      }
  }
  </code></pre>
  
  <p>When I do this, the windows are perfectly arranged:</p>
  
  <p><a href="https://i.stack.imgur.com/cneqK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cneqK.png" alt="enter image description here"></a></p>
  
  <p>However, as it is visible, some of the windows contents aren't resized with the window (Now, accidentally, they are the last 3, but it is not always the case. Sometimes there are more, and they are not always the last ones.)</p>
  
  <p>It is clearly visible, that the scene is the one that isn't resized with the window.</p>
  
  <p><a href="https://i.stack.imgur.com/cAJeU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cAJeU.png" alt="enter image description here"></a></p>
  
  <p>As soon as I resize the window manually, the controls are layed out well.</p>
  
  <p>I trled a bunch of things to hack this:</p>
  
  <ul>
  <li>Calling the requestLayout method manually</li>
  <li>Removing the root element from the scene and adding again</li>
  <li>Removing the scene from the stage and adding again</li>
  <li>Adding 100 ms delay between the resize operations</li>
  <li>binding the root elements width to the window width (minus border size)</li>
  </ul>
  
  <p>None of the above helped. (Yes, not even adding the scene again! It caused the most spectacular result, because the contents are resized to the window size, but with streaching its content.)</p>
  
  <p>Does anyone have any other idea how to hack this bug?</p>
  
  <p>I'm using Java 8u74.</p>