java.lang.Object | |
↳ | java.awt.dnd.DragSourceContext |
The 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 DragSourceListener
s
and DragSourceMotionListener
s, and providing the
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 DragSourceContextPeer
instance)
created by the DragSource
to notify
the DragSourceContext
of
state changes in the ongoing operation. This allows the
DragSourceContext
to interpose
itself between the platform and the
listeners provided by the initiator of the drag operation.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | CHANGED | An int used by updateCurrentCursor()
indicating that the user operation has changed. |
|||||||||
int | DEFAULT | An int used by updateCurrentCursor()
indicating that the Cursor should change
to the default (no drop) Cursor . |
|||||||||
int | ENTER | An int used by updateCurrentCursor()
indicating that the Cursor
has entered a DropTarget . |
|||||||||
int | OVER | An int used by updateCurrentCursor()
indicating that the Cursor is
over a DropTarget . |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Called from
DragSource , this constructor creates a new
DragSourceContext given the
DragSourceContextPeer for this Drag, the
DragGestureEvent that triggered the Drag, the initial
Cursor to use for the Drag, an (optional)
Image to display while the Drag is taking place, the offset
of the Image origin from the hotspot at the instant of the
triggering event, the Transferable subject data, and the
DragSourceListener to use during the Drag and Drop
operation. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a
DragSourceListener to this
DragSourceContext if one has not already been added. | |||||||||||
Calls
dragDropEnd on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceDropEvent . | |||||||||||
Calls
dragEnter on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceDragEvent . | |||||||||||
Calls
dragExit on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceEvent . | |||||||||||
Calls
dragMouseMoved on the
DragSourceMotionListener s registered with the
DragSource associated with this
DragSourceContext , and them passes the specified
DragSourceDragEvent . | |||||||||||
Calls
dragOver on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceDragEvent . | |||||||||||
Calls
dropActionChanged on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceDragEvent . | |||||||||||
Returns the
Component associated with this
DragSourceContext . | |||||||||||
Returns the current drag
Cursor . | |||||||||||
Returns the
DragSource
that instantiated this DragSourceContext . | |||||||||||
Returns a bitwise mask of
DnDConstants that
represent the set of drop actions supported by the drag source for the
drag operation associated with this DragSourceContext . | |||||||||||
Returns the
Transferable associated with
this DragSourceContext . | |||||||||||
Returns the
DragGestureEvent
that initially triggered the drag. | |||||||||||
Removes the specified
DragSourceListener
from this DragSourceContext . | |||||||||||
Sets the cursor for this drag operation to the specified
Cursor . | |||||||||||
Notifies the peer that the
Transferable 's
DataFlavor s have changed. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
If the default drag cursor behavior is active, this method
sets the default drag cursor for the specified actions
supported by the drag source, the drop target action,
and status, otherwise this method does nothing.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
An int
used by updateCurrentCursor()
indicating that the user operation has changed.
An int
used by updateCurrentCursor()
indicating that the Cursor
should change
to the default (no drop) Cursor
.
An int
used by updateCurrentCursor()
indicating that the Cursor
has entered a DropTarget
.
An int
used by updateCurrentCursor()
indicating that the Cursor
is
over a DropTarget
.
Called from DragSource
, this constructor creates a new
DragSourceContext
given the
DragSourceContextPeer
for this Drag, the
DragGestureEvent
that triggered the Drag, the initial
Cursor
to use for the Drag, an (optional)
Image
to display while the Drag is taking place, the offset
of the Image
origin from the hotspot at the instant of the
triggering event, the Transferable
subject data, and the
DragSourceListener
to use during the Drag and Drop
operation.
If DragSourceContextPeer
is null
NullPointerException
is thrown.
If DragGestureEvent
is null
NullPointerException
is thrown.
If Cursor
is null
no exception is thrown and
the default drag cursor behavior is activated for this drag operation.
If Image
is null
no exception is thrown.
If Image
is not null
and the offset is
null
NullPointerException
is thrown.
If Transferable
is null
NullPointerException
is thrown.
If DragSourceListener
is null
no exception
is thrown.
dscp | the DragSourceContextPeer for this drag |
---|---|
trigger | the triggering event |
dragCursor | the initial Cursor |
dragImage | the Image to drag (or null ) |
offset | the offset of the image origin from the hotspot at the instant of the triggering event |
t | the Transferable |
dsl | the DragSourceListener |
IllegalArgumentException | if the Component associated
with the trigger event is null . |
---|---|
IllegalArgumentException | if the DragSource for the
trigger event is null . |
IllegalArgumentException | if the drag action for the
trigger event is DnDConstants.ACTION_NONE . |
IllegalArgumentException | if the source actions for the
DragGestureRecognizer associated with the trigger
event are equal to DnDConstants.ACTION_NONE . |
NullPointerException | if dscp, trigger, or t are null, or if dragImage is non-null and offset is null |
Add a DragSourceListener
to this
DragSourceContext
if one has not already been added.
If a DragSourceListener
already exists,
this method throws a TooManyListenersException
.
dsl | the DragSourceListener to add.
Note that while null is not prohibited,
it is not acceptable as a parameter.
|
---|
if
a DragSourceListener has already been added
|
|
TooManyListenersException |
Calls dragDropEnd
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceDropEvent
.
dsde | the DragSourceDropEvent
|
---|
Calls dragEnter
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceDragEvent
.
dsde | the DragSourceDragEvent
|
---|
Calls dragExit
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceEvent
.
dse | the DragSourceEvent
|
---|
Calls dragMouseMoved
on the
DragSourceMotionListener
s registered with the
DragSource
associated with this
DragSourceContext
, and them passes the specified
DragSourceDragEvent
.
dsde | the DragSourceDragEvent |
---|
Calls dragOver
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceDragEvent
.
dsde | the DragSourceDragEvent
|
---|
Calls dropActionChanged
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceDragEvent
.
dsde | the DragSourceDragEvent
|
---|
Returns the Component
associated with this
DragSourceContext
.
Component
that started the drag
Returns the DragSource
that instantiated this DragSourceContext
.
DragSource
that
instantiated this DragSourceContext
Returns a bitwise mask of DnDConstants
that
represent the set of drop actions supported by the drag source for the
drag operation associated with this DragSourceContext
.
Returns the Transferable
associated with
this DragSourceContext
.
Transferable
Returns the DragGestureEvent
that initially triggered the drag.
Removes the specified DragSourceListener
from this DragSourceContext
.
dsl | the DragSourceListener to remove;
note that while null is not prohibited,
it is not acceptable as a parameter
|
---|
Sets the cursor for this drag operation to the specified
Cursor
. If the specified Cursor
is null
, the default drag cursor behavior is
activated for this drag operation, otherwise it is deactivated.
c | the Cursor to display, or
null to activate the default drag cursor
behavior
|
---|
Notifies the peer that the Transferable
's
DataFlavor
s have changed.
If the default drag cursor behavior is active, this method sets the default drag cursor for the specified actions supported by the drag source, the drop target action, and status, otherwise this method does nothing.
sourceAct | the actions supported by the drag source |
---|---|
targetAct | the drop target action |
status | one of the fields DEFAULT ,
ENTER , OVER ,
CHANGED
|