title: JavaFX - setOnAction not applicable
body: <p>I am trying to learn JavaFX, and I've written the code shown down below, however I seem to be having trouble with this line of code:</p>
  
  <pre><code>btn.setOnAction(new EventHandler&lt;ActionEvent&gt;()
  </code></pre>
  
  <p>where it underlines setOnAction, and prints this Error:</p>
  
  <pre><code> The method setOnAction(EventHandler&lt;ActionEvent&gt;) in the type ButtonBase is not applicable for the arguments (new EventHandler&lt;ActionEvent&gt;(){})
  </code></pre>
  
  
  
  <pre><code>import java.awt.event.ActionEvent;
  import javafx.application.Application;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.layout.StackPane;
  import javafx.stage.Stage;
  
  public class Test extends Application{
      public static void main(String[] args){
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) {
          primaryStage.setTitle("Hello World!");
          Button btn = new Button();
          btn.setText("Say 'Hello World' ");
          btn.setOnAction(new EventHandler&lt;ActionEvent&gt;(){
               @Override
               public void handle(ActionEvent event) {
                   System.out.println("Button clicked");
               }
           });
  
          StackPane root = new StackPane();
          root.getChildren().add(btn);
          primaryStage.setScene(new Scene(root, 300, 250));
          primaryStage.show();
  
      }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>