Package ca.cgjennings.ui.dnd
Class AbstractDragAndDropHandler<T>
- java.lang.Object
-
- ca.cgjennings.ui.dnd.AbstractDragAndDropHandler<T>
-
- All Implemented Interfaces:
DragHandler<T>
,DropHandler<T>
public abstract class AbstractDragAndDropHandler<T> extends java.lang.Object implements DragHandler<T>, DropHandler<T>
An abstract base class that combines aDragHandler
and aDropHandler
in a single object. This can be a useful basis for building interactions with reasonably simple drag logic, such as dragging and dropping between two containers. For convenience, the methodacceptDrop
returnstrue
; the methodsdragFinished
,dragEnter
,dragExit
, anddragMove
have empty implementations.- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description AbstractDragAndDropHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptDrop(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
Called to determine if a drop target is willing to accept a particular drop.void
dragEnter(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
Called when the cursor enters a viable drop target.void
dragExit(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget)
Called when the cursor leaves a drop target (or moves over part of the target that will not accept the drop).void
dragFinished(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget)
Called when a drag gesture finishes, whether the drag token was successfully dropped or not.void
dragMove(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
Called when the cursor is moved over a viable drop target.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ca.cgjennings.ui.dnd.DragHandler
createDragToken
-
Methods inherited from interface ca.cgjennings.ui.dnd.DropHandler
handleDrop
-
-
-
-
Method Detail
-
acceptDrop
public boolean acceptDrop(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
Description copied from interface:DropHandler
Called to determine if a drop target is willing to accept a particular drop.- Specified by:
acceptDrop
in interfaceDropHandler<T>
- Parameters:
manager
- the manager that is managing the dragdragSource
- the component being dragged fromtoken
- the token that was draggeddropTarget
- the target that the token would be dropped onlocation
- the location of the potential drop- Returns:
true
if the handler would allow the drop,false
otherwise
-
dragFinished
public void dragFinished(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget)
Description copied from interface:DragHandler
Called when a drag gesture finishes, whether the drag token was successfully dropped or not. This method is called after- Specified by:
dragFinished
in interfaceDragHandler<T>
- Parameters:
manager
- the manager that is managing the dragdragSource
- the component being dragged fromtoken
- the token that was draggeddropTarget
- the target that the token was dropped on, ornull
if the drag was cancelled
-
dragEnter
public void dragEnter(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
Description copied from interface:DropHandler
Called when the cursor enters a viable drop target. This can be used to update the visual representation of the target.- Specified by:
dragEnter
in interfaceDropHandler<T>
- Parameters:
manager
- the manager that is managing the dragdragSource
- the component being dragged fromtoken
- the token that was draggeddropTarget
- the target that the token is being dropped onlocation
- the location of the cursor
-
dragExit
public void dragExit(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget)
Description copied from interface:DropHandler
Called when the cursor leaves a drop target (or moves over part of the target that will not accept the drop). This can be used to update the visual representation of the target.- Specified by:
dragExit
in interfaceDropHandler<T>
- Parameters:
manager
- the manager that is managing the dragdragSource
- the component being dragged fromtoken
- the token that was draggeddropTarget
- the target that the token is being dropped on
-
dragMove
public void dragMove(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
Description copied from interface:DropHandler
Called when the cursor is moved over a viable drop target. This can be used to update the visual representation of the target.- Specified by:
dragMove
in interfaceDropHandler<T>
- Parameters:
manager
- the manager that is managing the dragdragSource
- the component being dragged fromtoken
- the token that was draggeddropTarget
- the target that the token is being dropped onlocation
- the location of the cursor
-
-