net.lucidviews.util.gui.swing.dnd
Class DefaultDropTarget

java.lang.Object
  extended by java.awt.dnd.DropTarget
      extended by net.lucidviews.util.gui.swing.dnd.DefaultDropTarget
All Implemented Interfaces:
DropTargetListener, Serializable, EventListener
Direct Known Subclasses:
DefaultSwingDropTarget

public class DefaultDropTarget
extends DropTarget

An extension of the DropTarget class that invokes state changes on the drag'n'drop event.

This class must be sub-classed and the drag/drop methods overridden with custom implementations. NB: overridden methods must call the super method to invoke the state change on the event.
Sub classes will probably want to override the dataFlavourSupported too, to control the type of data being dropped onto the target.

Since:
1.3
Version:
$Revision: 1.1.2.1 $
Author:
Stephen Battey
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.dnd.DropTarget
DropTarget.DropTargetAutoScroller
 
Field Summary
protected  boolean canImport
          A flag to remember whether import is being allowed for each drop event sent to this target.
private static long serialVersionUID
          Serialisation version id.
protected  int supportedActions
          A bit mask of flags for actions supported by this target.
 
Constructor Summary
protected DefaultDropTarget(Component component, int supportedActions)
          Create a drop target for the specified component.
 
Method Summary
private  boolean actionSupported(int action)
          Check if an action is supported by this drop target.
protected  boolean dataFlavourSupported(Component component, DataFlavor[] flavours)
          Check if a data type is accepted by this drop target.
 void dragEnter(DropTargetDragEvent e)
          
 void dragExit(DropTargetEvent e)
          
 void dragOver(DropTargetDragEvent e)
          
 void drop(DropTargetDropEvent e)
          
 void dropActionChanged(DropTargetDragEvent e)
          
 
Methods inherited from class java.awt.dnd.DropTarget
addDropTargetListener, addNotify, clearAutoscroll, createDropTargetAutoScroller, createDropTargetContext, getComponent, getDefaultActions, getDropTargetContext, getFlavorMap, initializeAutoscrolling, isActive, removeDropTargetListener, removeNotify, setActive, setComponent, setDefaultActions, setFlavorMap, updateAutoscroll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serialisation version id.

See Also:
Constant Field Values

supportedActions

protected int supportedActions
A bit mask of flags for actions supported by this target.


canImport

protected boolean canImport
A flag to remember whether import is being allowed for each drop event sent to this target.

Constructor Detail

DefaultDropTarget

protected DefaultDropTarget(Component component,
                            int supportedActions)
Create a drop target for the specified component.

Parameters:
component - the GUI component that is to accept DnDs
supportedActions - the actions that will be supported - a bit mask of DnDConstants
Method Detail

actionSupported

private boolean actionSupported(int action)
Check if an action is supported by this drop target.

Parameters:
action - the action is taking place - a bit mask of DnDConstants
Returns:
true if the action is supported by this drop target

dataFlavourSupported

protected boolean dataFlavourSupported(Component component,
                                       DataFlavor[] flavours)
Check if a data type is accepted by this drop target.
By default, all data flavours are supported. This method can be overridden to change that behaviour.

Parameters:
component - the component being targeted
flavours - the data flavour(s) of the incoming drag'n'drop event
Returns:
a Boolean value indicating if the data flavour is accepted by this drop target

dragEnter

public void dragEnter(DropTargetDragEvent e)

Specified by:
dragEnter in interface DropTargetListener
Overrides:
dragEnter in class DropTarget

dragOver

public void dragOver(DropTargetDragEvent e)

Specified by:
dragOver in interface DropTargetListener
Overrides:
dragOver in class DropTarget

dragExit

public void dragExit(DropTargetEvent e)

Specified by:
dragExit in interface DropTargetListener
Overrides:
dragExit in class DropTarget

drop

public void drop(DropTargetDropEvent e)

Specified by:
drop in interface DropTargetListener
Overrides:
drop in class DropTarget

dropActionChanged

public void dropActionChanged(DropTargetDragEvent e)

Specified by:
dropActionChanged in interface DropTargetListener
Overrides:
dropActionChanged in class DropTarget