/** * Adds drag and drop functionality. * * @param comp component * @param dnd drag and drop handler */ public static void addDrop(final JComponent comp, final DropHandler dnd) { comp.setDropTarget( new DropTarget(comp, DnDConstants.ACTION_COPY_OR_MOVE, null, true, null) { @Override public synchronized void drop(final DropTargetDropEvent dtde) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); final Transferable tr = dtde.getTransferable(); for (final Object o : contents(tr)) dnd.drop(o); comp.requestFocusInWindow(); } }); }