@SuppressWarnings("unchecked") @Override public void drop(DropTargetDropEvent dtde) { for (DataFlavor dataFlover : dtde.getCurrentDataFlavors()) { if (dataFlover.isFlavorJavaFileListType()) { try { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); for (File file : (List<File>) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)) { if (file.isFile() && file.canRead()) { fileText.setText(file.getCanonicalPath()); break; } } dtde.getDropTargetContext().dropComplete(true); } catch (UnsupportedFlavorException e1) { // } catch (IOException e2) { // } } } }
@Override public boolean canImport(TransferSupport support) { if (support.isDrop() && !mDropEnabled) return false; if (support.getComponent() == mTextArea && mTextHandler.canImport(support)) return true; for (DataFlavor flavor : support.getDataFlavors()) { if (flavor.isFlavorJavaFileListType()) { return true; } } return false; }
public static void main(String[] args) throws Exception { df = new DataFlavor("application/x-java-file-list;class=java.util.ArrayList"); boolean fl = df.isFlavorJavaFileListType(); finished = true; if (!fl) throw new RuntimeException("Test FAILED"); }