O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required