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 GUI014 extends Application { @Override public void start(Stage mainStage) throws Exception { Button but = new Button("Click me"); but.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) { System.out.println("Clicked"); } }); Scene sc = new Scene(but, 200, 100); mainStage.setScene(sc); mainStage.show(); } public static void main(String[] args) { Application.launch(args); } }