I'm trying to make a simple application, which use DnD to get file path. I found here practicly the same thing, which I would like to use. But I got an Error - typ List does not take parameters. When i try DnD just if it works, I get positive answer, but I don't know any other possibility, how to get file path. Here's code, which I use:
jTextField8.setDropTarget(new DropTarget() {
public synchronized void drop(DropTargetDropEvent evt) {
try {
evt.acceptDrop(DnDConstants.ACTION_COPY);
List<File> droppedFiles = (List<File>) evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
for (File file : droppeFiles) {
jTextArea1.append("Drag & Drop OK");
}
} catch (UnsupportedFlavorException ex) {
Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
});