package hellofx; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; public class GUI013 extends Application { @Override public void start(Stage mainStage) throws Exception { Button but = new Button("Click me"); MyHandler handler = new MyHandler(); but.setOnAction(handler); Scene sc = new Scene(but, 200, 100); mainStage.setScene(sc); mainStage.show(); } public static void main(String[] args) { Application.launch(args); } } class MyHandler implements EventHandler { @Override public void handle(ActionEvent e) { System.out.println("Clicked"); } }