package test; import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public final class ClickTest extends Application { @Override public void start(final Stage stage) { final Rectangle rectangle = new Rectangle(20, 20, 300, 200); rectangle.setFill(Color.BLUE); rectangle.setOnMouseClicked( new EventHandler() { @Override public void handle(final MouseEvent mouseEvent) { System.out.println("Rectangle: click count = " + mouseEvent.getClickCount()); } }); final Scene scene = new Scene(new Group(rectangle), 400, 300); scene.setOnMouseClicked( new EventHandler() { @Override public void handle(final MouseEvent mouseEvent) { System.out.println("Scene: click count = " + mouseEvent.getClickCount()); } }); stage.setTitle("Click Test"); stage.setScene(scene); stage.show(); } public static void main(final String... args) { Application.launch(args); } }