Question on Java Oracle Community (https://community.oracle.com/thread/3934986)
The Problem:
I have set the code below for a Button
which it's full name represents a file path.So when the Button
is dragged to a folder or desktop(let's say in Windows
) it is copied by user's Operating System.
I want to get the target folder on which the drop has been done.
Code:
button.setOnDragDetected(event -> {
/* allow copy transfer mode */
Dragboard db = startDragAndDrop(TransferMode.COPY,TransferMode.LINK);
/* put a string on dragboard */
ClipboardContent content = new ClipboardContent();
/*Adding a file into the ClipboardContent*/
content.putFiles(Arrays.asList(new File(getSongPath())));
........//not showing this code....
db.setContent(content);
event.consume();
}
Edit:(29/09/2016)
When the drop is done:
setOnDragDone(d -> {
System.out.println(
"Drag Done,is drop completed?" + d.isDropCompleted() + " , is accepted?" + d.isAccepted());
System.out.println("Accepted Mode:" + d.getAcceptedTransferMode());
System.out.println(" Target:" + d.getTarget() + " Gestoure Target:" + d.getGestureTarget());
});
I get this output where you can see that the Gesture Target == null
Drag Done:true , s drop completed?false , is accepted?true
Accepted Mode:COPY
Target:SmartController$TableViewer@112437[styleClass=table-view] Gesture Target:null