I have a java swing based application with a drag and drop functionality. When I run this application via cmd everything is working fine. But when I run the same application via eclipse the 'drag and drop' functionality is not working. What could be the problem ?
txtrDragYourFile.setDropTarget(new DropTarget() {
@SuppressWarnings("unchecked")
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 : droppedFiles) {
txtrDragYourFile.setText(file.getAbsolutePath());
System.out.println("File path is '" + file.getPath() + "'.");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
This happened to me as well while running Eclipse as administrator. Running eclipse normally solved the problem for me.
I had the same problem with eclipse-java-neon-1. After upgrading to newest version the problem was gone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.