public class DnDHandler
extends java.lang.Object
implements java.awt.dnd.peer.DragSourceContextPeer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Hashtable |
actionTable |
protected java.awt.Component |
comp |
protected java.util.Hashtable |
contextTable |
protected java.awt.Cursor |
cursor |
protected java.awt.dnd.DropTargetContext |
dropContext |
protected java.awt.dnd.DragSourceContext |
dsc |
protected java.awt.Cursor |
oldCursor |
protected java.awt.Component |
over |
protected java.awt.Component |
root |
| Constructor and Description |
|---|
DnDHandler(java.awt.dnd.DragGestureEvent trigger)
Constructs a DnDHandler using the drag gesture trigger
|
| Modifier and Type | Method and Description |
|---|---|
static java.awt.dnd.DragSource |
createDragSource()
This creates the appropriate drag source.
|
static java.awt.dnd.DropTarget |
createDropTarget(java.awt.Component c,
java.awt.dnd.DropTargetListener dtl)
This creates the appropriate drop target.
|
java.awt.Cursor |
getCursor()
Returns the current cursor
|
protected int |
getDropAction(java.awt.event.MouseEvent e)
Returns the correct drop action based on the event
|
protected java.awt.Component |
getDropTarget(java.awt.event.MouseEvent e)
Gets the drop target component from the mouse event
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Called when the mouse has been pressed and released
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Called when the mouse is being dragged
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Called when the mouse has entered the component
|
void |
mouseExited(java.awt.event.MouseEvent e)
Called when the mouse leaves the component
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Called when the mouse has moved
|
void |
mousePressed(java.awt.event.MouseEvent e)
Called when the mouse is pressed.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Called when the mouse is released.
|
void |
setCursor(java.awt.Cursor cursor)
Sets the current cursor
|
void |
startDrag(java.awt.dnd.DragSourceContext dsc,
java.awt.Cursor cursor,
java.awt.Image dragImage,
java.awt.Point imageOffset)
Starts the drag operation for a drag context
|
void |
transferablesFlavorsChanged()
Called if the transferable data flavors change
|
protected java.awt.Cursor cursor
protected java.awt.Cursor oldCursor
protected java.awt.dnd.DragSourceContext dsc
protected java.awt.Component comp
protected java.awt.Component over
protected java.util.Hashtable actionTable
protected java.util.Hashtable contextTable
protected java.awt.Component root
protected java.awt.dnd.DropTargetContext dropContext
public DnDHandler(java.awt.dnd.DragGestureEvent trigger)
trigger - The DragGestureEventpublic void startDrag(java.awt.dnd.DragSourceContext dsc,
java.awt.Cursor cursor,
java.awt.Image dragImage,
java.awt.Point imageOffset)
throws java.awt.dnd.InvalidDnDOperationException
startDrag in interface java.awt.dnd.peer.DragSourceContextPeerdsc - The DragSourceContextcursor - The initial cursordragImage - The image to be show during draggingimageOffset - The offset of the image from the cursorjava.awt.dnd.InvalidDnDOperationExceptionpublic java.awt.Cursor getCursor()
getCursor in interface java.awt.dnd.peer.DragSourceContextPeerpublic void setCursor(java.awt.Cursor cursor)
throws java.awt.dnd.InvalidDnDOperationException
setCursor in interface java.awt.dnd.peer.DragSourceContextPeercursor - The current cursorjava.awt.dnd.InvalidDnDOperationExceptionpublic void transferablesFlavorsChanged()
transferablesFlavorsChanged in interface java.awt.dnd.peer.DragSourceContextPeerprotected java.awt.Component getDropTarget(java.awt.event.MouseEvent e)
e - The mouse eventprotected int getDropAction(java.awt.event.MouseEvent e)
e - The mouse eventpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenere - The mouse eventpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenere - The mouse eventpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenere - The mouse eventpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenere - The mouse eventpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenere - The mouse eventpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenere - The mouse eventpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenere - The mouse eventpublic static java.awt.dnd.DragSource createDragSource()
public static java.awt.dnd.DropTarget createDropTarget(java.awt.Component c,
java.awt.dnd.DropTargetListener dtl)
c - the component which is the drop targetdtl - The drop raget listener