title: javafx show progressindicator while loading
body: <p>This is the main window of my application:</p>
  
  <p><img src="https://i.imgur.com/y1B0WZz.jpg" alt="screenshot"></p>
  
  <p>I want to be able to update the window, so i wrote a method <code>reset</code> which ist triggered by pressing F5:</p>
  
  <pre><code>public void reset() {
      final ProgressIndicator pi = new ProgressIndicator(-1.0f);
  
      final HBox hb = new HBox(pi);
      final VBox vb = new VBox(hb);
  
      hb.setAlignment(Pos.CENTER);
      vb.setAlignment(Pos.CENTER);
  
      scene.setRoot(vb);
  
      //this.show();
  }
  </code></pre>
  
  <p>if i run this it looks sth like this:</p>
  
  <p><img src="https://i.imgur.com/HxZAYsZ.png" alt="screenshot"></p>
  
  <p>However, if I uncomment the line <code>//this.show();</code> this will be executed:</p>
  
  <pre><code>public void show() {
      final VBox box = API_CALL_AND_BUILDING_BOX_MAGIC_WHICH_I_STRIPPED;
  
      gp.getChildren().clear();
      gp.getChildren().add(box);
  
      scene.setRoot(gp);
      stage.sizeToScene();
  }
  </code></pre>
  
  <p>and I will never be able to see my ProgressIndicator because the application will just hang until the APIcall is finished and the new content is loaded.</p>
  
  <p>I tried a bit with Threads and Platform.runLater() but I cant get it to work. My goal is to display the ProgressIndicator until the APIcall is finished, the box is build and the scene gets given <code>gp</code> as the new root.</p>
  
  <p>I hope its somewhat understandable what my goal and my problems are :)</p>