DragSourceContext
class is responsible for managing the initiator side of the Drag and Drop protocol. In particular, it is responsible for managing drag event notifications to the {@linkplain DragSourceListener DragSourceListeners}and {@linkplain DragSourceMotionListener DragSourceMotionListeners}, and providing the {@link Transferable} representing the source data for the drag operation. Note that the DragSourceContext
itself implements the DragSourceListener
and DragSourceMotionListener
interfaces. This is to allow the platform peer (the {@link DragSourceContextPeer} instance)created by the {@link DragSource} to notifythe DragSourceContext
of state changes in the ongoing operation. This allows the DragSourceContext
object to interpose itself between the platform and the listeners provided by the initiator of the drag operation.
By default, {@code DragSourceContext} sets the cursor as appropriatefor the current state of the drag and drop operation. For example, if the user has chosen {@linkplain DnDConstants#ACTION_MOVE the move action}, and the pointer is over a target that accepts the move action, the default move cursor is shown. When the pointer is over an area that does not accept the transfer, the default "no drop" cursor is shown.
This default handling mechanism is disabled when a custom cursor is set by the {@link #setCursor} method. When the default handling is disabled,it becomes the responsibility of the developer to keep the cursor up to date, by listening to the {@code DragSource} events and calling the {@code setCursor()} method.Alternatively, you can provide custom cursor behavior by providing custom implementations of the {@code DragSource}and the {@code DragSourceContext} classes. @see DragSourceListener @see DragSourceMotionListener @see DnDConstants @since 1.2
|
|