Hello I’ve been working on javafx 2.0. JavaFX has very flexible and customizable controls. The JavaFX is specially for GUI purpose only . So Today I would like to show how to make a Draggable Node in Javafx 2.0.

First Let’s make one customNode class which extends from the Parent. Ok now let’s see the class .

I think the above code is quite simple for the java programmer. I actually used four variable for saving x and y position. The x and y position of Mouse and other x and y position of Node.

Now let’s see the use of Draggable Node .

Css “main.css”

Ok now that’s it. Just run the program and you will see the Rectangle with 50px right and it’s draggable too.
If you like to see the demo then see at here: Draggable Node

*But remember that if you use the controls inside children of customNode then the draggable won’t work at all. Because the focus is taken by the Controls

Please don’t feel hesitate on commenting . Have a good day and Thanks for viewing blog. 🙂