Example usage for javafx.scene.control Button setOnMouseEntered

List of usage examples for javafx.scene.control Button setOnMouseEntered

Introduction

In this page you can find the example usage for javafx.scene.control Button setOnMouseEntered.

Prototype

public final void setOnMouseEntered(EventHandler<? super MouseEvent> value) 

Source Link

Usage

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  ww  .j a  va 2  s.  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();
}