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 aDragHandlerand aDropHandlerin 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 methodacceptDropreturnstrue; the methodsdragFinished,dragEnter,dragExit, anddragMovehave 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 booleanacceptDrop(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.voiddragEnter(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.voiddragExit(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).voiddragFinished(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.voiddragMove(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:DropHandlerCalled to determine if a drop target is willing to accept a particular drop.- Specified by:
acceptDropin 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:
trueif the handler would allow the drop,falseotherwise
-
dragFinished
public void dragFinished(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget)
Description copied from interface:DragHandlerCalled when a drag gesture finishes, whether the drag token was successfully dropped or not. This method is called after- Specified by:
dragFinishedin 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, ornullif 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:DropHandlerCalled when the cursor enters a viable drop target. This can be used to update the visual representation of the target.- Specified by:
dragEnterin 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:DropHandlerCalled 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:
dragExitin 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:DropHandlerCalled when the cursor is moved over a viable drop target. This can be used to update the visual representation of the target.- Specified by:
dragMovein 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
-
-