Java examples for JavaFX:Node
add JavaFX Draggable Node
//package com.java2s; import javafx.scene.Node; import javafx.scene.input.MouseEvent; public class Main { static double dragInitialX; static double dragInitialY; public static void addDraggableNode(final Node node) { node.setOnMousePressed((MouseEvent me) -> { dragInitialX = me.getSceneX();/* www .j a va 2s .c om*/ dragInitialY = me.getSceneY(); }); node.setOnMouseDragged((MouseEvent me) -> { node.getScene().getWindow().setX(me.getScreenX() - dragInitialX); node.getScene().getWindow().setY(me.getScreenY() - dragInitialY); }); } }