is new.
java.lang.Objectjava.awt.dnd.DragSourceContext
public class 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 DragSourceListeners and DragSourceMotionListeners, 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.
| Field Summary | |
|---|---|
| protected static int |
CHANGED
An int used by updateCurrentCursor() indicating that the user operation has changed. |
| protected static int |
DEFAULT
An int used by updateCurrentCursor() indicating that the Cursor should change to the default (no drop) Cursor. |
| protected static int |
ENTER
An int used by updateCurrentCursor() indicating that the Cursor has entered a DropTarget. |
| protected static int |
OVER
An int used by updateCurrentCursor() indicating that the Cursor is over a DropTarget. |
| Constructor Summary | |
|---|---|
|
DragSourceContext
(java.awt.dnd.peer.DragSourceContextPeer dscp,
DragGestureEvent
trigger,
Cursor
dragCursor,
Image
dragImage,
Point
offset,
Transferable
t,
DragSourceListener
dsl) 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. |
|
| Method Summary | |
|---|---|
| void |
addDragSourceListener
(
DragSourceListener
dsl) Add a DragSourceListener to this DragSourceContext if one has not already been added. |
| void |
dragDropEnd
(
DragSourceDropEvent
dsde) Calls dragDropEnd on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDropEvent. |
| void |
dragEnter
(
DragSourceDragEvent
dsde) Calls dragEnter on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent. |
| void |
dragExit
(
DragSourceEvent
dse) Calls dragExit on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceEvent. |
| void |
dragMouseMoved
(
DragSourceDragEvent
dsde) Calls dragMouseMoved on the DragSourceMotionListeners registered with the DragSource associated with this DragSourceContext, and them passes the specified DragSourceDragEvent. |
| void |
dragOver
(
DragSourceDragEvent
dsde) Calls dragOver on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent. |
| void |
dropActionChanged
(
DragSourceDragEvent
dsde) Calls dropActionChanged on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent. |
| Component |
getComponent
() Returns the Component associated with this DragSourceContext. |
| Cursor |
getCursor
() Returns the current drag Cursor. |
| DragSource |
getDragSource
() Returns the DragSource that instantiated this DragSourceContext. |
| int |
getSourceActions
() 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. |
| Transferable |
getTransferable
() Returns the Transferable associated with this DragSourceContext. |
| DragGestureEvent |
getTrigger
() Returns the DragGestureEvent that initially triggered the drag. |
| void |
removeDragSourceListener
(
DragSourceListener
dsl) Removes the specified DragSourceListener from this DragSourceContext. |
| void |
setCursor
(
Cursor
c) Sets the cursor for this drag operation to the specified Cursor. |
| void |
transferablesFlavorsChanged
() Notifies the peer that the Transferable's DataFlavors have changed. |
| protected void |
updateCurrentCursor
(int sourceAct,
If the default drag cursor behavior is active, this method sets the default drag cursor for the specified
supported by the drag source, the drop target action,
and status, otherwise this method does nothing. |
| Methods inherited from class java.lang. Object |
|---|
| clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
| Field Detail |
|---|
protected static final int DEFAULT
protected static final int ENTER
protected static final int OVER
protected static final int CHANGED
| Constructor Detail |
|---|
public DragSourceContext(java.awt.dnd.peer.DragSourceContextPeer dscp,
DragGestureEvent trigger,
Cursor dragCursor,
Image dragImage,
Point offset,
Transferable t,
DragSourceListener dsl)
| Method Detail |
|---|
public DragSource getDragSource()
public Component getComponent()
public DragGestureEvent getTrigger()
public int getSourceActions()
public void setCursor(Cursor c)
public Cursor getCursor()
public void addDragSourceListener(DragSourceListener dsl)
throws TooManyListenersException
public void removeDragSourceListener(DragSourceListener dsl)
public void transferablesFlavorsChanged()
public void dragEnter(DragSourceDragEvent dsde)
public void dragOver(DragSourceDragEvent dsde)
public void dragExit(DragSourceEvent dse)
public void dropActionChanged(DragSourceDragEvent dsde)
public void dragDropEnd(DragSourceDropEvent dsde)
public void dragMouseMoved(DragSourceDragEvent dsde)
public Transferable getTransferable()
protected void updateCurrentCursor(int sourceAct,
(int dropOp,int targetAct, int status)
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