|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.swing.XDragSource
public abstract class XDragSource
An abstract base class for drag sources.
This class implements both drag gesture and drag source listeners for any AWT component and handles the details of the source side of drag and drop operations.
Concrete subclasses must implement the dragGestureRecognized method. This method should compute both the drag image and the drag data, then call the startDrag method in this class to start the drag. The startDrag method computes the proper offset for the drag image and tells the drag gesture event to start the drag using the image and data supplied by the subclass.
Empty implementations are provided for the required drag enter, drag over, drag exit, and drop action changed event handlers. Subclasses may override these handlers if they wish.
This class has an incestuous relationship with its partner XDropTarget
class and its subclasses:
ghost
image and notifies XDropTarget
that all drop targets must drag the ghost image around as the mouse moves
into and over each target.
XDropTarget
when each drag and drop operation ends by calling
XDropTarget.stopCurrentTarget
.
Constructor Summary | |
---|---|
XDragSource(java.awt.Component component)
Constructs a new drag source object. |
Method Summary | |
---|---|
void |
dragDropEnd(java.awt.dnd.DragSourceDropEvent dsde)
Handles a drag drop end event. |
void |
dragEnter(java.awt.dnd.DragSourceDragEvent dsde)
Handles a drag enter event. |
void |
dragExit(java.awt.dnd.DragSourceEvent dse)
Handles a drag exit event. |
abstract void |
dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
Handles a drag gesture recognized event. |
void |
dragOver(java.awt.dnd.DragSourceDragEvent dsde)
Handles a drag over event. |
void |
dropActionChanged(java.awt.dnd.DragSourceDragEvent dsde)
Handles a drop action changed event. |
static java.awt.datatransfer.Transferable |
getCurrentDragData()
Gets the current drag data. |
static java.awt.Component |
getCurrentDragSource()
Gets the current drag source component. |
static java.awt.event.InputEvent |
getTriggerEvent()
Gets the trigger event for the most recent drag. |
void |
startDrag(java.awt.dnd.DragGestureEvent dge,
java.awt.Rectangle bounds,
java.awt.image.BufferedImage image,
java.awt.datatransfer.Transferable transferable)
Starts a drag. |
void |
startDrag(java.awt.dnd.DragGestureEvent dge,
java.awt.Rectangle bounds,
java.awt.image.BufferedImage image,
java.awt.datatransfer.Transferable transferable,
java.awt.Cursor cursor)
Starts a drag. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XDragSource(java.awt.Component component)
A new default drag gesture recognizer is created for the component.
component
- The drag source component. Method Detail |
---|
public static java.awt.Component getCurrentDragSource()
public static java.awt.datatransfer.Transferable getCurrentDragData()
public static java.awt.event.InputEvent getTriggerEvent()
public void startDrag(java.awt.dnd.DragGestureEvent dge, java.awt.Rectangle bounds, java.awt.image.BufferedImage image, java.awt.datatransfer.Transferable transferable, java.awt.Cursor cursor)
dge
- The drag gesture event.bounds
- The bounds of the drag image.image
- The drag image.transferable
- The drag data.cursor
- The drag cursor. public void startDrag(java.awt.dnd.DragGestureEvent dge, java.awt.Rectangle bounds, java.awt.image.BufferedImage image, java.awt.datatransfer.Transferable transferable)
dge
- The drag gesture event.bounds
- The bounds of the drag image.image
- The drag image.transferable
- The drag data. public void dragDropEnd(java.awt.dnd.DragSourceDropEvent dsde)
Subclasses may override this method, but must remember to invoke super.dragDropEnd.
dragDropEnd
in interface java.awt.dnd.DragSourceListener
dsde
- The event. public void dragEnter(java.awt.dnd.DragSourceDragEvent dsde)
dragEnter
in interface java.awt.dnd.DragSourceListener
dsde
- The event. public void dragExit(java.awt.dnd.DragSourceEvent dse)
dragExit
in interface java.awt.dnd.DragSourceListener
dse
- The event. public void dragOver(java.awt.dnd.DragSourceDragEvent dsde)
dragOver
in interface java.awt.dnd.DragSourceListener
dsde
- The event. public void dropActionChanged(java.awt.dnd.DragSourceDragEvent dsde)
dropActionChanged
in interface java.awt.dnd.DragSourceListener
dsde
- The event. public abstract void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
dragGestureRecognized
in interface java.awt.dnd.DragGestureListener
dge
- The event.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |