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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.