List of usage examples for javafx.scene.control Button setOnMousePressed
public final void setOnMousePressed(EventHandler<? super MouseEvent> value)
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250); Button btn = new Button(); btn.setText("Hello World"); btn.setOnMouseEntered(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { System.out.println("Mouse entered"); }//from w w w. jav a 2s . c o m }); btn.setOnMouseExited(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { System.out.println("Mouse exited"); } }); btn.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { System.out.println("Mouse pressed"); } }); root.getChildren().add(btn); primaryStage.setScene(scene); primaryStage.show(); }