title: Updating your UI and forcibly waiting before continuing JavaFX
body: <p>I show here an image of my welcome scene.</p>
  
  <p><a href="https://i.stack.imgur.com/zYnuE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zYnuE.png" alt="image"></a></p>
  
  <p>The current behavior of the <b>Create New Project</b> button is shown here:</p>
  
  <pre><code>Stage stage = (Stage)((Node)event.getSource()).getScene().getWindow();
  stage.hide();
  Parent root = FXMLLoader.load(getClass().getResource("/view/scene/configure/NewProjectConfigureScene.fxml"));
  Scene scene = new Scene(root);
  stage.setTitle("Configure New Project Settings");
  stage.setScene(scene);
  stage.show();
  </code></pre>
  
  <p>To explain it in words: the button is pressed -> I get the stage -> hide the current scene -> switch the stage to have a new scene -> re-display the stage. This behavior is working.</p>
  
  <p>I am new to GUI programming so please bear with me as I explain what I need.</p>
  
  <p>I am now trying to add a small feature where when the <b>Create New Project</b> button is pressed, a loading message appears in the current scene, I force the GUI to wait for a few seconds (so that the user has time to see this "loading" message) before continuing onto the next scene. The loading message would look something like this.</p>
  
  <p><a href="https://i.stack.imgur.com/9GdRU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9GdRU.png" alt="image"></a></p>
  
  <p>I really want to implement this feature because a loading message followed by a wait could be more intuitive and consequently improve my users experience when using the program.</p>
  
  <p>My initial attempt was to do the following:</p>
  
  <pre><code>statusText.setText("Please wait..."); // statusText is the "loading message"
  Stage stage = (Stage)((Node)event.getSource()).getScene().getWindow();
  try {
      Thread.sleep(2000);                
  } catch(InterruptedException ex) {
      Thread.currentThread().interrupt();
  }
  stage.hide();
  
  Parent root = FXMLLoader.load(getClass().getResource("/view/scene/configure/NewProjectConfigureScene.fxml"));
  Scene scene = new Scene(root);
  stage.setTitle("Configure New Project Settings");
  stage.setScene(scene);
  stage.show();
  </code></pre>
  
  <p>I just read <a href="https://stackoverflow.com/questions/29800410/make-javafx-application-thread-wait-for-another-thread-to-finish">here</a> that you can never sleep the UI thread because it will freeze the entire application. So I've been trying the approach mentioned in the first answer from the above link, which says to use <code>javafx.concurrent.Task</code>, however I have been trying for a long time to no avail.</p>
  
  <p>How do I update the UI, forcibly wait for a few seconds, and then display a new scene?</p>