title: Using Thread.sleep to get waiting effect in JavaFX
body: <p>I want to achieve something like this: user press the login button and then label shows:
  "Connecting." <br>
  0.5 sec time interval <br>
  "Connecting.." <br>
  0.5 sec time interval <br>
  "Connecting..." <br>
  etc</p>
  
  <p>Just a visual effect that indicates something is actually going on "under the hood". </p>
  
  <p>All I managed to get wasn't quite what I was expecting. I click the button, wait 1.5 sec and then I got "Connecting...", missing 2 previous steps. </p>
  
  <p>First, my <code>Status</code> class </p>
  
  <pre><code>public class Status {
      private static StringProperty status = new SimpleStringProperty();
  
      public static void setStatus(String newStatus) {
          status.setValue(newStatus);
      }
  
      public static String getStatus() {
          return status.getValue();
      }
  
      public static StringProperty get() {
          return status;
      }
  }
  </code></pre>
  
  <p>and my <code>LoginView</code> class</p>
  
  <pre><code>public class LoginView extends Application {
  
     private Button loginButton = new Button("Log in");
     private Label statusLabel;
  
     private void createLabels() {        
        statusLabel = new Label(Status.getStatus());
        statusLabel.textProperty().bind(Status.get());
     }
  
  }  
  
   private void createButtons() {        
          loginButton.setOnAction(e -&gt; {
              try {
                  Status.setStatus("Connecting.");
                  Thread.sleep(500);
                  Status.setStatus("Connecting..");
                  Thread.sleep(500);
                  Status.setStatus("Connecting...");
                  Thread.sleep(500);
              } catch (InterruptedException e1) {
                  e1.printStackTrace();
              }
          });
      }
  </code></pre>