During DnD operations it is possible that a user may wish to drop the subject of the operation on a region of a scrollable GUI control that is not currently visible to the user.
The listener interface for receiving drag gesture events.
A listener interface for receiving mouse motion events during a drag operation.
This class contains constant values representing the type of action(s) to be performed by a Drag and Drop operation.
An abstract adapter class for receiving drag source events.
This class is the base class for
this protected nested class implements autoscrolling
An abstract adapter class for receiving drop target events.
This abstract subclass of
This exception is thrown by various methods in the java.awt.dnd package.
This package defines the classes and interfaces necessary to perform Drag and Drop operations in Java. It defines classes for the drag-source and the drop-target, as well as events for transferring the data being dragged. This package also provides a means for giving visual feedback to the user throughout the duration of the Drag and Drop operation.
A typical Drag and Drop operation can be decomposed into the following states (not entirely sequentially):
DragSourcecomes into existence, associated with some presentation element (
Component) in the GUI, to initiate a Drag and Drop of some potentially
DropTarget(s) come into/go out of existence, associated with presentation elements in the GUI (Components), potentially capable of consuming
DragGestureRecognizeris obtained from the
DragSourceand is associated with a
Componentin order to track and identify any Drag initiating gesture by the user over the
Component, which the registered
DragGestureRecognizerdetects, and notifies its
Note: Although this API consistently refers to the stimulus for a
drag and drop operation being a physical gesture by a human user, this
does not preclude a programmatically driven DnD operation given the
appropriate implementation of a
DragSource. This package
contains the abstract class
recognizing mouse device gestures. Other abstract subclasses may be
provided by the platform to support other input devices or
Component class semantics.
DragSourceto initiate the Drag and Drop operation on behalf of the user, perhaps animating the GUI Cursor and/or rendering an
Imageof the item(s) that are the subject of the operation.
Component(s) in the GUI with associated
DragSourcereceives notifications in order to provide "Drag Over" feedback effects, and the
DropTarget(s) receive notifications in order to provide "Drag Under" feedback effects based upon the operation(s) supported and the data type(s) involved.
The gesture itself moves a logical cursor across the GUI hierarchy,
intersecting the geometry of GUI Component(s), possibly resulting in
the logical "Drag" cursor entering, crossing, and subsequently
Component(s) and associated
DragSource object manifests "Drag Over" feedback to the user, in the typical case by animating the GUI
Cursor associated with the
DropTarget objects manifest "Drag Under" feedback to the user, in
the typical case, by rendering animations into their associated GUI
Component(s) under the GUI Cursor.
The determination of the feedback effects, and the ultimate success or failure of the data transfer, should one occur, is parameterized as follows:
DropTarget: Copy, Move or Reference(link).
DragSourceand the set of data types comprehensible by the
DropTargetreceive notifications that include, and result in the type negotiation and transfer of, the information associated with the
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.