JavaFX MouseEvent display mouse event
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; import javafx.scene.text.Text; import javafx.stage.Stage; public class Main extends Application { @Override // w ww . jav a 2 s . com public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create and register the handler pane.setOnMouseClicked((MouseEvent e) -> { pane.getChildren().clear(); pane.getChildren().add(new Text(e.getX(), e.getY(), "(" + e.getX() + ", " + e.getY() + ")")); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 200); primaryStage.setTitle("java2s.com"); primaryStage.setScene(scene); primaryStage.show(); } }