java.awt.dnd
Class DropTarget

java.lang.Object
  |
  +--java.awt.dnd.DropTarget
All Implemented Interfaces:
DropTargetListener, EventListener, Serializable
Direct Known Subclasses:
javax.swing.TransferHandler.SwingDropTarget

public class DropTarget
extends Object
implements DropTargetListener, Serializable

Unsafe:

See Also:
Serialized Form

Field Summary
(package private)  int actions
          Default permissible actions supported by this DropTarget.
(package private)  boolean active
          true if the DropTarget is accepting Drag & Drop operations.
private  java.awt.dnd.DropTarget.DropTargetAutoScroller autoScroller
           
private  Component component
          The Component associated with this DropTarget.
private  java.awt.peer.ComponentPeer componentPeer
           
private static FlavorMap defaultFlavorMap
           
private  DropTargetContext dropTargetContext
          The DropTargetContext associated with this DropTarget.
private  DropTargetListener dtListener
           
private  FlavorMap flavorMap
           
private  java.awt.peer.ComponentPeer nativePeer
           
private static long serialVersionUID
           
 
Constructor Summary
DropTarget()
          Enabled: Creates a DropTarget.
DropTarget(Component c, DropTargetListener dtl)
          Enabled: Creates a DropTarget given the Component to associate itself with, and the DropTargetListener to handle event processing.
DropTarget(Component c, int ops, DropTargetListener dtl)
          Enabled: Creates a DropTarget given the Component to associate itself with, an int representing the default acceptable action(s) to support, and a DropTargetListener to handle event processing.
DropTarget(Component c, int ops, DropTargetListener dtl, boolean act)
          Enabled: Creates a DropTarget given the Component to associate itself with, an int representing the default acceptable action(s) to support, a DropTargetListener to handle event processing, and a boolean indicating if the DropTarget is currently accepting drops.
DropTarget(Component c, int ops, DropTargetListener dtl, boolean act, FlavorMap fm)
          Enabled: Creates a new DropTarget given the Component to associate itself with, an int representing the default acceptable action(s) to support, a DropTargetListener to handle event processing, a boolean indicating if the DropTarget is currently accepting drops, and a FlavorMap to use (or null for the default FlavorMap).
 
Method Summary
 void addDropTargetListener(DropTargetListener dtl)
          Enabled: Adds a new DropTargetListener (UNICAST SOURCE).
 void addNotify(java.awt.peer.ComponentPeer peer)
          Suppressed: Notify the DropTarget that it has been associated with a Component This method is usually called from java.awt.Component.addNotify() of the Component associated with this DropTarget to notify the DropTarget that a ComponentPeer has been associated with that Component.
protected  void clearAutoscroll()
          clear autoscrolling
protected  java.awt.dnd.DropTarget.DropTargetAutoScroller createDropTargetAutoScroller(Component c, Point p)
          create an embedded autoscroller
protected  DropTargetContext createDropTargetContext()
          Creates the DropTargetContext associated with this DropTarget.
(package private)  void doSetDefaultActions(int ops)
           
 void dragEnter(DropTargetDragEvent dtde)
          Enabled: The DropTarget intercepts dragEnter() notifications before the registered DropTargetListener gets them.
 void dragExit(DropTargetEvent dte)
          Enabled: The DropTarget intercepts dragExit() notifications before the registered DropTargetListener gets them.
 void dragOver(DropTargetDragEvent dtde)
          Enabled: The DropTarget intercepts dragOver() notifications before the registered DropTargetListener gets them.
 void drop(DropTargetDropEvent dtde)
          Enabled: The DropTarget intercepts drop() notifications before the registered DropTargetListener gets them.
 void dropActionChanged(DropTargetDragEvent dtde)
          Enabled: The DropTarget intercepts dropActionChanged() notifications before the registered DropTargetListener gets them.
 Component getComponent()
          Suppressed: Gets the Component associated with this DropTarget.
 int getDefaultActions()
          Enabled: Gets an int representing the current action(s) supported by this DropTarget.
 DropTargetContext getDropTargetContext()
          Enabled: Gets the DropTargetContext associated with this DropTarget.
 FlavorMap getFlavorMap()
          Enabled: Gets the FlavorMap associated with this DropTarget.
protected  void initializeAutoscrolling(Point p)
          initialize autoscrolling
 boolean isActive()
          Enabled: Reports whether or not this DropTarget is currently active (ready to accept drops).
private  void readObject(ObjectInputStream s)
          Deserializes this DropTarget.
 void removeDropTargetListener(DropTargetListener dtl)
          Enabled: Removes the current DropTargetListener (UNICAST SOURCE).
 void removeNotify(java.awt.peer.ComponentPeer peer)
          Suppressed: Notify the DropTarget that it has been disassociated from a Component This method is usually called from java.awt.Component.removeNotify() of the Component associated with this DropTarget to notify the DropTarget that a ComponentPeer has been disassociated with that Component.
 void setActive(boolean isActive)
          Enabled: Sets the DropTarget active if true, inactive if false.
 void setComponent(Component c)
          Enabled: Note: this interface is required to permit the safe association of a DropTarget with a Component in one of two ways, either: component.setDropTarget(droptarget); or droptarget.setComponent(component);
 void setDefaultActions(int ops)
          Enabled: Sets the default acceptable actions for this DropTarget
 void setFlavorMap(FlavorMap fm)
          Enabled: Sets the FlavorMap associated with this DropTarget.
protected  void updateAutoscroll(Point dragCursorLocn)
          update autoscrolling with current cursor locn
private  void writeObject(ObjectOutputStream s)
          Serializes this DropTarget.
 
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

defaultFlavorMap

private static final FlavorMap defaultFlavorMap

dropTargetContext

private DropTargetContext dropTargetContext
The DropTargetContext associated with this DropTarget.


component

private Component component
The Component associated with this DropTarget.


componentPeer

private transient java.awt.peer.ComponentPeer componentPeer

nativePeer

private transient java.awt.peer.ComponentPeer nativePeer

actions

int actions
Default permissible actions supported by this DropTarget.

See Also:
setDefaultActions(int), getDefaultActions()

active

boolean active
true if the DropTarget is accepting Drag & Drop operations.


autoScroller

private transient java.awt.dnd.DropTarget.DropTargetAutoScroller autoScroller

dtListener

private transient DropTargetListener dtListener

flavorMap

private transient FlavorMap flavorMap
Constructor Detail

DropTarget

public DropTarget(Component c,
                  int ops,
                  DropTargetListener dtl,
                  boolean act,
                  FlavorMap fm)
           throws HeadlessException
Enabled: Creates a new DropTarget given the Component to associate itself with, an int representing the default acceptable action(s) to support, a DropTargetListener to handle event processing, a boolean indicating if the DropTarget is currently accepting drops, and a FlavorMap to use (or null for the default FlavorMap).

The Component will receive drops only if it is enabled.

Parameters:
c - The Component with which this DropTarget is associated
ops - The default acceptable actions for this DropTarget
dtl - The DropTargetListener for this DropTarget
act - Is the DropTarget accepting drops.
fm - The FlavorMap to use, or null for the default FlavorMap
See Also:
java.awt.GraphicsEnvironment#isHeadless

DropTarget

public DropTarget(Component c,
                  int ops,
                  DropTargetListener dtl,
                  boolean act)
           throws HeadlessException
Enabled: Creates a DropTarget given the Component to associate itself with, an int representing the default acceptable action(s) to support, a DropTargetListener to handle event processing, and a boolean indicating if the DropTarget is currently accepting drops.

The Component will receive drops only if it is enabled.

Parameters:
c - The Component with which this DropTarget is associated
ops - The default acceptable actions for this DropTarget
dtl - The DropTargetListener for this DropTarget
act - Is the DropTarget accepting drops.
See Also:
java.awt.GraphicsEnvironment#isHeadless

DropTarget

public DropTarget()
           throws HeadlessException
Enabled: Creates a DropTarget.

See Also:
java.awt.GraphicsEnvironment#isHeadless

DropTarget

public DropTarget(Component c,
                  DropTargetListener dtl)
           throws HeadlessException
Enabled: Creates a DropTarget given the Component to associate itself with, and the DropTargetListener to handle event processing.

The Component will receive drops only if it is enabled.

Parameters:
c - The Component with which this DropTarget is associated
dtl - The DropTargetListener for this DropTarget
See Also:
java.awt.GraphicsEnvironment#isHeadless

DropTarget

public DropTarget(Component c,
                  int ops,
                  DropTargetListener dtl)
           throws HeadlessException
Enabled: Creates a DropTarget given the Component to associate itself with, an int representing the default acceptable action(s) to support, and a DropTargetListener to handle event processing.

The Component will receive drops only if it is enabled.

Parameters:
c - The Component with which this DropTarget is associated
ops - The default acceptable actions for this DropTarget
dtl - The DropTargetListener for this DropTarget
See Also:
java.awt.GraphicsEnvironment#isHeadless
Method Detail

setComponent

public void setComponent(Component c)
Enabled: Note: this interface is required to permit the safe association of a DropTarget with a Component in one of two ways, either: component.setDropTarget(droptarget); or droptarget.setComponent(component);

The Component will receive drops only if it is enabled.

Parameters:
c - The new Component this DropTarget is to be associated with.


getComponent

public Component getComponent()
Suppressed: Gets the Component associated with this DropTarget.

Returns:
the current Component

setDefaultActions

public void setDefaultActions(int ops)
Enabled: Sets the default acceptable actions for this DropTarget

Parameters:
ops - the default actions

See Also:
java.awt.dnd.DnDConstants

doSetDefaultActions

void doSetDefaultActions(int ops)

getDefaultActions

public int getDefaultActions()
Enabled: Gets an int representing the current action(s) supported by this DropTarget.

Returns:
the current default actions

setActive

public void setActive(boolean isActive)
Enabled: Sets the DropTarget active if true, inactive if false.

Parameters:
isActive - sets the DropTarget (in)active.

isActive

public boolean isActive()
Enabled: Reports whether or not this DropTarget is currently active (ready to accept drops).

Returns:
true if active, false if not

addDropTargetListener

public void addDropTargetListener(DropTargetListener dtl)
                           throws TooManyListenersException
Enabled: Adds a new DropTargetListener (UNICAST SOURCE).

Parameters:
dtl - The new DropTargetListener

Throws:
TooManyListenersException - if a DropTargetListener is already added to this DropTarget.
TooManyListenersException

removeDropTargetListener

public void removeDropTargetListener(DropTargetListener dtl)
Enabled: Removes the current DropTargetListener (UNICAST SOURCE).

Parameters:
dtl - the DropTargetListener to deregister.

dragEnter

public void dragEnter(DropTargetDragEvent dtde)
Enabled: The DropTarget intercepts dragEnter() notifications before the registered DropTargetListener gets them.

Specified by:
dragEnter in interface DropTargetListener
Parameters:
dtde - the DropTargetDragEvent

dragOver

public void dragOver(DropTargetDragEvent dtde)
Enabled: The DropTarget intercepts dragOver() notifications before the registered DropTargetListener gets them.

Specified by:
dragOver in interface DropTargetListener
Parameters:
dtde - the DropTargetDragEvent

dropActionChanged

public void dropActionChanged(DropTargetDragEvent dtde)
Enabled: The DropTarget intercepts dropActionChanged() notifications before the registered DropTargetListener gets them.

Specified by:
dropActionChanged in interface DropTargetListener
Parameters:
dtde - the DropTargetDragEvent

dragExit

public void dragExit(DropTargetEvent dte)
Enabled: The DropTarget intercepts dragExit() notifications before the registered DropTargetListener gets them.

Specified by:
dragExit in interface DropTargetListener
Parameters:
dte - the DropTargetEvent

drop

public void drop(DropTargetDropEvent dtde)
Enabled: The DropTarget intercepts drop() notifications before the registered DropTargetListener gets them.

Specified by:
drop in interface DropTargetListener
Parameters:
dtde - the DropTargetDropEvent

getFlavorMap

public FlavorMap getFlavorMap()
Enabled: Gets the FlavorMap associated with this DropTarget. If no FlavorMap has been set for this DropTarget, it is associated with the default FlavorMap.

Returns:
the FlavorMap for this DropTarget

setFlavorMap

public void setFlavorMap(FlavorMap fm)
Enabled: Sets the FlavorMap associated with this DropTarget.

Parameters:
fm - the new FlavorMap, or null to associate the default FlavorMap with this DropTarget.

addNotify

public void addNotify(java.awt.peer.ComponentPeer peer)
Suppressed: Notify the DropTarget that it has been associated with a Component This method is usually called from java.awt.Component.addNotify() of the Component associated with this DropTarget to notify the DropTarget that a ComponentPeer has been associated with that Component. Calling this method, other than to notify this DropTarget of the association of the ComponentPeer with the Component may result in a malfunction of the DnD system.

Parameters:
peer - The Peer of the Component we are associated with!

removeNotify

public void removeNotify(java.awt.peer.ComponentPeer peer)
Suppressed: Notify the DropTarget that it has been disassociated from a Component This method is usually called from java.awt.Component.removeNotify() of the Component associated with this DropTarget to notify the DropTarget that a ComponentPeer has been disassociated with that Component. Calling this method, other than to notify this DropTarget of the disassociation of the ComponentPeer from the Component may result in a malfunction of the DnD system.

Parameters:
peer - The Peer of the Component we are being disassociated from!

getDropTargetContext

public DropTargetContext getDropTargetContext()
Enabled: Gets the DropTargetContext associated with this DropTarget.

Returns:
the DropTargetContext associated with this DropTarget.

createDropTargetContext

protected DropTargetContext createDropTargetContext()
Creates the DropTargetContext associated with this DropTarget. Subclasses may override this method to instantiate their own DropTargetContext subclass. This call is typically *only* called by the platform's DropTargetContextPeer as a drag operation encounters this DropTarget. Accessing the Context while no Drag is current has undefined results.


writeObject

private void writeObject(ObjectOutputStream s)
                  throws IOException
Serializes this DropTarget. Performs default serialization, and then writes out this object's DropTargetListener if and only if it can be serialized. If not, null is written instead.

IOException
Since:
1.4

readObject

private void readObject(ObjectInputStream s)
                 throws ClassNotFoundException,
                        IOException
Deserializes this DropTarget. This method first performs default deserialization for all non-transient fields. An attempt is then made to deserialize this object's DropTargetListener as well. This is first attempted by deserializing the field dtListener, because, in releases prior to 1.4, a non-transient field of this name stored the DropTargetListener. If this fails, the next object in the stream is used instead.

ClassNotFoundException
IOException
Since:
1.4

createDropTargetAutoScroller

protected java.awt.dnd.DropTarget.DropTargetAutoScroller createDropTargetAutoScroller(Component c,
                                                                                      Point p)
create an embedded autoscroller

Parameters:
c - the Component
p - the Point

initializeAutoscrolling

protected void initializeAutoscrolling(Point p)
initialize autoscrolling

Parameters:
p - the Point

updateAutoscroll

protected void updateAutoscroll(Point dragCursorLocn)
update autoscrolling with current cursor locn

Parameters:
dragCursorLocn - the Point

clearAutoscroll

protected void clearAutoscroll()
clear autoscrolling



comments?