List of usage examples for java.awt.dnd DropTargetContext dropComplete
public void dropComplete(boolean success) throws InvalidDnDOperationException
From source file:xtrememp.PlaylistManager.java
@Override @SuppressWarnings("unchecked") public void drop(DropTargetDropEvent ev) { DropTargetContext targetContext = ev.getDropTargetContext(); Transferable t = ev.getTransferable(); try {/* ww w . ja v a 2s.c o m*/ // Windows if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { ev.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); addFiles((List<File>) t.getTransferData(DataFlavor.javaFileListFlavor), false); targetContext.dropComplete(true); // Linux } else if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) { ev.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); String urls = (String) t.getTransferData(DataFlavor.stringFlavor); List<File> fileList = new ArrayList<>(); StringTokenizer st = new StringTokenizer(urls); while (st.hasMoreTokens()) { URI uri = new URI(st.nextToken()); fileList.add(new File(uri)); } addFiles(fileList, false); targetContext.dropComplete(true); } } catch (UnsupportedFlavorException | InvalidDnDOperationException | IOException | URISyntaxException ex) { logger.error(ex.getMessage(), ex); } }