Example usage for javafx.scene.control Button setOnMouseExited

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

Introduction

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

Prototype

public final void setOnMouseExited(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   ww w  .j  a v a  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();
}