title: How to disable a button while processing
body: <p>How can I disable a JavaFX button while something is processing (to prevent user from spamming the button)? </p>
  
  <pre><code>primaryStage.setTitle("Update Stuff");
  
  Label lbl = new Label();
  lbl.setText("Nothing here yet");
  
  Button btn = new Button();
  btn.setText("Update");
  btn.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
  
      @Override
      public void handle(ActionEvent event) {
          btn.setDisable(true); //I tried this, but to no avail
          lbl.setText(getNumberOfViewers()); // this might take a few seconds, need to disable button during this time
          btn.setDisable(false);
      }
  });
  
  VBox root = new VBox();
  root.setAlignment(Pos.CENTER);
  root.getChildren().addAll(btn, lbl);
  primaryStage.setScene(new Scene(root, 200, 100));
  primaryStage.show();
  </code></pre>