Drag Sources and Drop Targets

Drag sources and drop targets are the fundamental building blocks upon which drag and drop is based. Drag sources, represented by the DragSource class, initiate a drag with the DragSource.startDrag method. Drop targets, represented by the DropTarget class, are targets for dropped data with the DropTarget.drop method.

As mentioned previously, drag and drop is initiated with a gesture. Typically, the gesture entails dragging the mouse outside of the bounds of a drag source; however, the gesture is window system dependent. The java.awt.dnd package provides a DragGestureRecognizer class for detecting a drag gesture. Instances of DragGestureRecognizer can be obtained from a drag source. The recognizer notifies a drag ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.