Implementing drag-and-drop from one JPanel to another

java, swing

Solution

May be this can help you.

Drag and Drop of complex custom objects in Java

Problem

I'm new to drag-and-drop in Swing. I have a `JPanel` that draws an image with a caption superimposed on it. I want to implement drag and drop on this `JPanel`, but after going through some documentation and tutorials I didn't find any usable pointers on how it's done for this type of component. For starters, it doesn't have a `setDragEnabled` function. Can I make a `JPanel` draggable? I want to use this DnD maneuver to pass a reference to a certain object from one panel to another.

Original source