[英]Drag and Drop not working when run via Eclipse
我有一個基於java swing的應用程序,具有拖放功能。 當我通過cmd運行此應用程序時,一切正常。 但是當我通過eclipse運行相同的應用程序時,“拖放”功能無效。 可能是什么問題呢 ?
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();
}
}
});
在以管理員身份運行Eclipse時,這也發生在我身上。 運行eclipse通常可以解決我的問題。
我和eclipse-java-neon-1有同樣的問題。 升級到最新版本后,問題就消失了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.