Example usage for javafx.scene Node setOnMouseDragged

List of usage examples for javafx.scene Node setOnMouseDragged

Introduction

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

Prototype

public final void setOnMouseDragged(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   www .  j  a  va  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);
    });
}