public class DnDHandler
extends java.lang.Object
implements java.awt.dnd.peer.DragSourceContextPeer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
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
|
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
|
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.DragSourceContextPeer
dsc
- The DragSourceContextcursor
- The initial cursordragImage
- The image to be show during draggingimageOffset
- The offset of the image from the cursorjava.awt.dnd.InvalidDnDOperationException
public java.awt.Cursor getCursor()
getCursor
in interface java.awt.dnd.peer.DragSourceContextPeer
public void setCursor(java.awt.Cursor cursor) throws java.awt.dnd.InvalidDnDOperationException
setCursor
in interface java.awt.dnd.peer.DragSourceContextPeer
cursor
- The current cursorjava.awt.dnd.InvalidDnDOperationException
public void transferablesFlavorsChanged()
transferablesFlavorsChanged
in interface java.awt.dnd.peer.DragSourceContextPeer
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
e
- The mouse eventpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
e
- The mouse eventpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
e
- The mouse eventpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
e
- The mouse eventpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
e
- The mouse eventpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
e
- The mouse eventpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
e
- 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