|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.citra.common.gui.DndSupport
public abstract class DndSupport
The DndSupport support class enables drag and drop for a component. It implements all three interfaces for registering itself as a listener for drag starting (DragGestureListener), drag (DragSourceListener) and drop events (DropTargetListener).
Subclasses should implement the dragStarted and dragStopped methods, as well as override any needed empty interface methods, such as dragGestureRecognized or drop.
Field Summary | |
---|---|
protected Component |
component
the component for which drag and drop is enabled |
Constructor Summary | |
---|---|
DndSupport(Component component)
Constructs a DndSupport. |
Method Summary | |
---|---|
void |
dragDropEnd(DragSourceDropEvent dsde)
This method is invoked to signify that the Drag and Drop operation is complete. |
void |
dragEnter(DragSourceDragEvent dsde)
Called as the cursor's hotspot enters a platform-dependent drop site. |
void |
dragEnter(DropTargetDragEvent e)
Called while a drag operation is ongoing, when the mouse pointer enters the operable part of the drop site for the DropTarget
registered with this listener. |
void |
dragExit(DragSourceEvent dse)
Called as the cursor's hotspot exits a platform-dependent drop site. |
void |
dragExit(DropTargetEvent e)
Called while a drag operation is ongoing, when the mouse pointer has exited the operable part of the drop site for the DropTarget registered with this listener. |
void |
dragGestureRecognized(DragGestureEvent dge)
A DragGestureRecognizer has detected
a platform-dependent drag initiating gesture and
is notifying this listener
in order for it to initiate the action for the user. |
void |
dragOver(DragSourceDragEvent dsde)
Called as the cursor's hotspot moves over a platform-dependent drop site. |
void |
dragOver(DropTargetDragEvent e)
Called when a drag operation is ongoing, while the mouse pointer is still over the operable part of the drop site for the DropTarget
registered with this listener. |
protected abstract void |
dragStarted(MouseEvent e)
Called when a mouse button has been pressed on the component. |
protected abstract void |
dragStopped(MouseEvent e)
Called when a mouse button has been released on the component. |
void |
drop(DropTargetDropEvent e)
Called when the drag operation has terminated with a drop on the operable part of the drop site for the DropTarget
registered with this listener. |
void |
dropActionChanged(DragSourceDragEvent dsde)
Called when the user has modified the drop gesture. |
void |
dropActionChanged(DropTargetDragEvent e)
Called if the user has modified the current drop gesture. |
Component |
getComponent()
Returns the component for which drag and drop is enabled. |
void |
setComponent(Component component)
Assigns the component for which drag and drop is enabled. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Component component
Constructor Detail |
---|
public DndSupport(Component component)
Method Detail |
---|
public void dragDropEnd(DragSourceDropEvent dsde)
DragSourceDropEvent
can be used to
determine the termination state. The getDropAction() method
returns the operation that the drop site selected
to apply to the Drop operation. Once this method is complete, the
current DragSourceContext
and
associated resources become invalid.
dragDropEnd
in interface DragSourceListener
dsde
- the DragSourceDropEvent
public void dragEnter(DragSourceDragEvent dsde)
dragEnter
in interface DragSourceListener
dsde
- the DragSourceDragEvent
public void dragEnter(DropTargetDragEvent e)
DropTarget
registered with this listener.
dragEnter
in interface DropTargetListener
e
- the DropTargetDragEvent
public void dragExit(DragSourceEvent dse)
dragExit
in interface DragSourceListener
dse
- the DragSourceEvent
public void dragExit(DropTargetEvent e)
DropTarget
registered with this listener.
dragExit
in interface DropTargetListener
e
- the DropTargetEvent
public void dragGestureRecognized(DragGestureEvent dge)
DragGestureRecognizer
has detected
a platform-dependent drag initiating gesture and
is notifying this listener
in order for it to initiate the action for the user.
dragGestureRecognized
in interface DragGestureListener
dge
- the DragGestureEvent
describing
the gesture that has just occurredpublic void dragOver(DragSourceDragEvent dsde)
dragOver
in interface DragSourceListener
dsde
- the DragSourceDragEvent
public void dragOver(DropTargetDragEvent e)
DropTarget
registered with this listener.
dragOver
in interface DropTargetListener
e
- the DropTargetDragEvent
protected abstract void dragStarted(MouseEvent e)
dragGestureRecognized
method is called.
e
- the mouse pressed event triggering the start of a drag eventprotected abstract void dragStopped(MouseEvent e)
e
- the mouse released event triggering the stop of a drag eventpublic void drop(DropTargetDropEvent e)
DropTarget
registered with this listener.
This method is responsible for undertaking
the transfer of the data associated with the
gesture. The DropTargetDropEvent
provides a means to obtain a Transferable
object that represents the data object(s) to
be transfered.
From this method, the DropTargetListener
shall accept or reject the drop via the
acceptDrop(int dropAction) or rejectDrop() methods of the
DropTargetDropEvent
parameter.
Subsequent to acceptDrop(), but not before,
DropTargetDropEvent
's getTransferable()
method may be invoked, and data transfer may be
performed via the returned Transferable
's
getTransferData() method.
At the completion of a drop, an implementation
of this method is required to signal the success/failure
of the drop by passing an appropriate
boolean
to the DropTargetDropEvent
's
dropComplete(boolean success) method.
Note: The data transfer should be completed before the call to the
DropTargetDropEvent
's dropComplete(boolean success) method.
After that, a call to the getTransferData() method of the
Transferable
returned by
DropTargetDropEvent.getTransferable()
is guaranteed to
succeed only if the data transfer is local; that is, only if
DropTargetDropEvent.isLocalTransfer()
returns
true
. Otherwise, the behavior of the call is
implementation-dependent.
drop
in interface DropTargetListener
e
- the DropTargetDropEvent
public void dropActionChanged(DragSourceDragEvent dsde)
dropActionChanged
in interface DragSourceListener
dsde
- the DragSourceDragEvent
public void dropActionChanged(DropTargetDragEvent e)
dropActionChanged
in interface DropTargetListener
e
- the DropTargetDragEvent
public Component getComponent()
public void setComponent(Component component)
component
- the drag n' drop enabled component to assign
|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |