Reputation: 2440
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.
Upvotes: 4
Views: 5108
Reputation: 846
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.
Upvotes: 4