How to get the selected virtual file from a DnDEvent

How to get  the selected virtual file from a DnDEvent?
I want to get selected virtual file from a DnDEvent to put into a JTextField.

1 comment
Comment actions Permalink

DnDEvent works together with the standard AWT drag & drop mechanism, which has no concept of virtual files. To get the list of dragged files from a DnDEvent, use:

if (dndEvent.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
    List<File> files = (List<File>) dndEvent.getTransferData(DataFlavor.javaFileListFlavor);
    // proces the files
}

0

Please sign in to leave a comment.