Drag and drop event in JavaFX TableView


Question

I would like to add Drag and Drop support to my JavaFX application. My requirement is that if someone drags files from Native file system and drops to the JavaFX TableView then it must recognize the drop event and how can i get the list of drpped files.

1
4
11/26/2012 10:49:23 AM

Accepted Answer

I would use the official JavaFX 2 docs.

http://docs.oracle.com/javafx/2/drag_drop/jfxpub-drag_drop.htm

http://docs.oracle.com/javafx/2/drag_drop/HelloDragAndDrop.java.html

So you can understand the methods you'll need to handle the drag events:

target.setOnDragOver

target.setOnDragEntered

target.setOnDragExited

target.setOnDragDropped

Then with the DragEvent on these events you can use the getDragboard() to access the drag content, which inherits Clipboard. From here, you have some methods like getFiles, which is what you need.

4
11/26/2012 2:25:36 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon