Example usage for javafx.scene Node setOnMousePressed

List of usage examples for javafx.scene Node setOnMousePressed

Introduction

In this page you can find the example usage for javafx.scene Node setOnMousePressed.

Prototype

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

Source Link

Usage

From source file:Main.java

public static void addDraggableNode(final Node node) {

    node.setOnMousePressed((MouseEvent me) -> {
        dragInitialX = me.getSceneX();/*from  w w w .  j a v a 2  s.c om*/
        dragInitialY = me.getSceneY();
    });

    node.setOnMouseDragged((MouseEvent me) -> {
        node.getScene().getWindow().setX(me.getScreenX() - dragInitialX);
        node.getScene().getWindow().setY(me.getScreenY() - dragInitialY);
    });
}