java.awt.dnd
Class DragGestureRecognizer

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.dnd.DragGestureRecognizer
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable
Direct Known Subclasses:
MouseDragGestureRecognizer sample code for java.awt.dnd.MouseDragGestureRecognizer definition code for java.awt.dnd.MouseDragGestureRecognizer

public abstract class DragGestureRecognizer
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

The DragGestureRecognizer is an abstract base class for the specification of a platform-dependent listener that can be associated with a particular Component in order to identify platform-dependent drag initiating gestures.

The appropriate DragGestureRecognizer subclass is obtained from the DragSource asssociated with a particular Component, or from the Toolkit object via its createDragGestureRecognizer() method.

Once the DragGestureRecognizer is associated with a particular Component it will register the appropriate listener interfaces on that Component in order to track the input events delivered to the Component.

Once the DragGestureRecognizer identifies a sequence of events on the Component as a drag initiating gesture, it will notify its unicast DragGestureListener by invoking its gestureRecognized() method.

When a concrete DragGestureRecognizer instance detects a drag initiating gesture on the Component it is associated with, it will fire a DragGestureEvent to the DragGestureListener registered on its unicast event source for DragGestureListener events. This DragGestureListener is responsible for causing the associated DragSource to start the Drag and Drop operation (if appropriate).

See Also:
DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener , DragGestureEvent sample code for java.awt.dnd.DragGestureEvent definition code for java.awt.dnd.DragGestureEvent , DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource , Serialized Form

Field Summary
protected  Component sample code for java.awt.Component definition code for java.awt.Component component sample code for java.awt.dnd.DragGestureRecognizer.component definition code for java.awt.dnd.DragGestureRecognizer.component
          The Component associated with this DragGestureRecognizer.
protected  DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener dragGestureListener sample code for java.awt.dnd.DragGestureRecognizer.dragGestureListener definition code for java.awt.dnd.DragGestureRecognizer.dragGestureListener
          The DragGestureListener associated with this DragGestureRecognizer.
protected  DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource dragSource sample code for java.awt.dnd.DragGestureRecognizer.dragSource definition code for java.awt.dnd.DragGestureRecognizer.dragSource
          The DragSource associated with this DragGestureRecognizer.
protected  ArrayList sample code for java.util.ArrayList definition code for java.util.ArrayList <InputEvent sample code for java.awt.event.InputEvent definition code for java.awt.event.InputEvent > events sample code for java.awt.dnd.DragGestureRecognizer.events definition code for java.awt.dnd.DragGestureRecognizer.events
          The list of events (in order) that the DragGestureRecognizer "recognized" as a "gesture" that triggers a drag.
protected  int sourceActions sample code for java.awt.dnd.DragGestureRecognizer.sourceActions definition code for java.awt.dnd.DragGestureRecognizer.sourceActions
          An int representing the type(s) of action(s) used in this Drag and Drop operation.
 
Constructor Summary
protected DragGestureRecognizer sample code for java.awt.dnd.DragGestureRecognizer.DragGestureRecognizer(java.awt.dnd.DragSource) definition code for java.awt.dnd.DragGestureRecognizer.DragGestureRecognizer(java.awt.dnd.DragSource) (DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  ds)
          Construct a new DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation.
protected DragGestureRecognizer sample code for java.awt.dnd.DragGestureRecognizer.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component) definition code for java.awt.dnd.DragGestureRecognizer.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component) (DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  ds, Component sample code for java.awt.Component definition code for java.awt.Component  c)
          Construct a new DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, and the Component this DragGestureRecognizer should "observe" for drag initiating gestures.
protected DragGestureRecognizer sample code for java.awt.dnd.DragGestureRecognizer.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component, int) definition code for java.awt.dnd.DragGestureRecognizer.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component, int) (DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  ds, Component sample code for java.awt.Component definition code for java.awt.Component  c, int sa)
          Construct a new DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, the Component this DragGestureRecognizer should "observe" for drag initiating gestures, and the action(s) supported for this Drag and Drop operation.
protected DragGestureRecognizer sample code for java.awt.dnd.DragGestureRecognizer.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component, int, java.awt.dnd.DragGestureListener) definition code for java.awt.dnd.DragGestureRecognizer.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component, int, java.awt.dnd.DragGestureListener) (DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  ds, Component sample code for java.awt.Component definition code for java.awt.Component  c, int sa, DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener  dgl)
          Construct a new DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, the Component this DragGestureRecognizer should "observe" for drag initiating gestures, the action(s) supported for this Drag and Drop operation, and the DragGestureListener to notify once a drag initiating gesture has been detected.
 
Method Summary
 void addDragGestureListener sample code for java.awt.dnd.DragGestureRecognizer.addDragGestureListener(java.awt.dnd.DragGestureListener) definition code for java.awt.dnd.DragGestureRecognizer.addDragGestureListener(java.awt.dnd.DragGestureListener) (DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener  dgl)
          Register a new DragGestureListener.
protected  void appendEvent sample code for java.awt.dnd.DragGestureRecognizer.appendEvent(java.awt.event.InputEvent) definition code for java.awt.dnd.DragGestureRecognizer.appendEvent(java.awt.event.InputEvent) (InputEvent sample code for java.awt.event.InputEvent definition code for java.awt.event.InputEvent  awtie)
          Listeners registered on the Component by this Recognizer shall record all Events that are recognized as part of the series of Events that go to comprise a Drag and Drop initiating gesture via this API.
protected  void fireDragGestureRecognized sample code for java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(int, java.awt.Point) definition code for java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(int, java.awt.Point) (int dragAction, Point sample code for java.awt.Point definition code for java.awt.Point  p)
          Notify the DragGestureListener that a Drag and Drop initiating gesture has occurred.
 Component sample code for java.awt.Component definition code for java.awt.Component getComponent sample code for java.awt.dnd.DragGestureRecognizer.getComponent() definition code for java.awt.dnd.DragGestureRecognizer.getComponent() ()
          This method returns the Component that is to be "observed" by the DragGestureRecognizer for drag initiating gestures.
 DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource getDragSource sample code for java.awt.dnd.DragGestureRecognizer.getDragSource() definition code for java.awt.dnd.DragGestureRecognizer.getDragSource() ()
          This method returns the DragSource this DragGestureRecognizer will use in order to process the Drag and Drop operation.
 int getSourceActions sample code for java.awt.dnd.DragGestureRecognizer.getSourceActions() definition code for java.awt.dnd.DragGestureRecognizer.getSourceActions() ()
          This method returns an int representing the type of action(s) this Drag and Drop operation will support.
 InputEvent sample code for java.awt.event.InputEvent definition code for java.awt.event.InputEvent getTriggerEvent sample code for java.awt.dnd.DragGestureRecognizer.getTriggerEvent() definition code for java.awt.dnd.DragGestureRecognizer.getTriggerEvent() ()
          This method returns the first event in the series of events that initiated the Drag and Drop operation.
protected abstract  void registerListeners sample code for java.awt.dnd.DragGestureRecognizer.registerListeners() definition code for java.awt.dnd.DragGestureRecognizer.registerListeners() ()
          register this DragGestureRecognizer's Listeners with the Component subclasses must override this method
 void removeDragGestureListener sample code for java.awt.dnd.DragGestureRecognizer.removeDragGestureListener(java.awt.dnd.DragGestureListener) definition code for java.awt.dnd.DragGestureRecognizer.removeDragGestureListener(java.awt.dnd.DragGestureListener) (DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener  dgl)
          unregister the current DragGestureListener
 void resetRecognizer sample code for java.awt.dnd.DragGestureRecognizer.resetRecognizer() definition code for java.awt.dnd.DragGestureRecognizer.resetRecognizer() ()
          Reset the Recognizer, if its currently recognizing a gesture, ignore it.
 void setComponent sample code for java.awt.dnd.DragGestureRecognizer.setComponent(java.awt.Component) definition code for java.awt.dnd.DragGestureRecognizer.setComponent(java.awt.Component) (Component sample code for java.awt.Component definition code for java.awt.Component  c)
          set the Component that the DragGestureRecognizer is associated with registerListeners() and unregisterListeners() are called as a side effect as appropriate.
 void setSourceActions sample code for java.awt.dnd.DragGestureRecognizer.setSourceActions(int) definition code for java.awt.dnd.DragGestureRecognizer.setSourceActions(int) (int actions)
          This method sets the permitted source drag action(s) for this Drag and Drop operation.
protected abstract  void unregisterListeners sample code for java.awt.dnd.DragGestureRecognizer.unregisterListeners() definition code for java.awt.dnd.DragGestureRecognizer.unregisterListeners() ()
          unregister this DragGestureRecognizer's Listeners with the Component subclasses must override this method
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

dragSource sample code for java.awt.dnd.DragGestureRecognizer.dragSource

protected DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  dragSource
The DragSource associated with this DragGestureRecognizer.


component sample code for java.awt.dnd.DragGestureRecognizer.component

protected Component sample code for java.awt.Component definition code for java.awt.Component  component
The Component associated with this DragGestureRecognizer.


dragGestureListener sample code for java.awt.dnd.DragGestureRecognizer.dragGestureListener

protected transient DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener  dragGestureListener
The DragGestureListener associated with this DragGestureRecognizer.


sourceActions sample code for java.awt.dnd.DragGestureRecognizer.sourceActions

protected int sourceActions
An int representing the type(s) of action(s) used in this Drag and Drop operation.


events sample code for java.awt.dnd.DragGestureRecognizer.events

protected ArrayList sample code for java.util.ArrayList definition code for java.util.ArrayList <InputEvent sample code for java.awt.event.InputEvent definition code for java.awt.event.InputEvent > events
The list of events (in order) that the DragGestureRecognizer "recognized" as a "gesture" that triggers a drag.

Constructor Detail

DragGestureRecognizer sample code for java.awt.dnd.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component, int, java.awt.dnd.DragGestureListener) definition code for java.awt.dnd.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component, int, java.awt.dnd.DragGestureListener)

protected DragGestureRecognizer(DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  ds,
                                Component sample code for java.awt.Component definition code for java.awt.Component  c,
                                int sa,
                                DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener  dgl)
Construct a new DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, the Component this DragGestureRecognizer should "observe" for drag initiating gestures, the action(s) supported for this Drag and Drop operation, and the DragGestureListener to notify once a drag initiating gesture has been detected.

Parameters:
ds - the DragSource this DragGestureRecognizer will use to process the Drag and Drop operation
c - the Component this DragGestureRecognizer should "observe" the event stream to, in order to detect a drag initiating gesture. If this value is null, the DragGestureRecognizer is not associated with any Component.
sa - the set (logical OR) of the DnDConstants that this Drag and Drop operation will support
dgl - the DragGestureRecognizer to notify when a drag gesture is detected

Throws:
IllegalArgumentException - if ds is null.

DragGestureRecognizer sample code for java.awt.dnd.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component, int) definition code for java.awt.dnd.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component, int)

protected DragGestureRecognizer(DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  ds,
                                Component sample code for java.awt.Component definition code for java.awt.Component  c,
                                int sa)
Construct a new DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, the Component this DragGestureRecognizer should "observe" for drag initiating gestures, and the action(s) supported for this Drag and Drop operation.

Parameters:
ds - the DragSource this DragGestureRecognizer will use to process the Drag and Drop operation
c - the Component this DragGestureRecognizer should "observe" the event stream to, in order to detect a drag initiating gesture. If this value is null, the DragGestureRecognizer is not associated with any Component.
sa - the set (logical OR) of the DnDConstants that this Drag and Drop operation will support

Throws:
IllegalArgumentException - if ds is null.

DragGestureRecognizer sample code for java.awt.dnd.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component) definition code for java.awt.dnd.DragGestureRecognizer(java.awt.dnd.DragSource, java.awt.Component)

protected DragGestureRecognizer(DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  ds,
                                Component sample code for java.awt.Component definition code for java.awt.Component  c)
Construct a new DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, and the Component this DragGestureRecognizer should "observe" for drag initiating gestures.

Parameters:
ds - the DragSource this DragGestureRecognizer will use to process the Drag and Drop operation
c - the Component this DragGestureRecognizer should "observe" the event stream to, in order to detect a drag initiating gesture. If this value is null, the DragGestureRecognizer is not associated with any Component.

Throws:
IllegalArgumentException - if ds is null.

DragGestureRecognizer sample code for java.awt.dnd.DragGestureRecognizer(java.awt.dnd.DragSource) definition code for java.awt.dnd.DragGestureRecognizer(java.awt.dnd.DragSource)

protected DragGestureRecognizer(DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  ds)
Construct a new DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation.

Parameters:
ds - the DragSource this DragGestureRecognizer will use to process the Drag and Drop operation

Throws:
IllegalArgumentException - if ds is null.
Method Detail

registerListeners sample code for java.awt.dnd.DragGestureRecognizer.registerListeners() definition code for java.awt.dnd.DragGestureRecognizer.registerListeners()

protected abstract void registerListeners()
register this DragGestureRecognizer's Listeners with the Component subclasses must override this method


unregisterListeners sample code for java.awt.dnd.DragGestureRecognizer.unregisterListeners() definition code for java.awt.dnd.DragGestureRecognizer.unregisterListeners()

protected abstract void unregisterListeners()
unregister this DragGestureRecognizer's Listeners with the Component subclasses must override this method


getDragSource sample code for java.awt.dnd.DragGestureRecognizer.getDragSource() definition code for java.awt.dnd.DragGestureRecognizer.getDragSource()

public DragSource sample code for java.awt.dnd.DragSource definition code for java.awt.dnd.DragSource  getDragSource()
This method returns the DragSource this DragGestureRecognizer will use in order to process the Drag and Drop operation.

Returns:
the DragSource

getComponent sample code for java.awt.dnd.DragGestureRecognizer.getComponent() definition code for java.awt.dnd.DragGestureRecognizer.getComponent()

public Component sample code for java.awt.Component definition code for java.awt.Component  getComponent()
This method returns the Component that is to be "observed" by the DragGestureRecognizer for drag initiating gestures.

Returns:
The Component this DragGestureRecognizer is associated with

setComponent sample code for java.awt.dnd.DragGestureRecognizer.setComponent(java.awt.Component) definition code for java.awt.dnd.DragGestureRecognizer.setComponent(java.awt.Component)

public void setComponent(Component sample code for java.awt.Component definition code for java.awt.Component  c)
set the Component that the DragGestureRecognizer is associated with registerListeners() and unregisterListeners() are called as a side effect as appropriate.

Parameters:
c - The Component or null

getSourceActions sample code for java.awt.dnd.DragGestureRecognizer.getSourceActions() definition code for java.awt.dnd.DragGestureRecognizer.getSourceActions()

public int getSourceActions()
This method returns an int representing the type of action(s) this Drag and Drop operation will support.

Returns:
the currently permitted source action(s)

setSourceActions sample code for java.awt.dnd.DragGestureRecognizer.setSourceActions(int) definition code for java.awt.dnd.DragGestureRecognizer.setSourceActions(int)

public void setSourceActions(int actions)
This method sets the permitted source drag action(s) for this Drag and Drop operation.

Parameters:
actions - the permitted source drag action(s)

getTriggerEvent sample code for java.awt.dnd.DragGestureRecognizer.getTriggerEvent() definition code for java.awt.dnd.DragGestureRecognizer.getTriggerEvent()

public InputEvent sample code for java.awt.event.InputEvent definition code for java.awt.event.InputEvent  getTriggerEvent()
This method returns the first event in the series of events that initiated the Drag and Drop operation.

Returns:
the initial event that triggered the drag gesture

resetRecognizer sample code for java.awt.dnd.DragGestureRecognizer.resetRecognizer() definition code for java.awt.dnd.DragGestureRecognizer.resetRecognizer()

public void resetRecognizer()
Reset the Recognizer, if its currently recognizing a gesture, ignore it.


addDragGestureListener sample code for java.awt.dnd.DragGestureRecognizer.addDragGestureListener(java.awt.dnd.DragGestureListener) definition code for java.awt.dnd.DragGestureRecognizer.addDragGestureListener(java.awt.dnd.DragGestureListener)

public void addDragGestureListener(DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener  dgl)
                            throws TooManyListenersException sample code for java.util.TooManyListenersException definition code for java.util.TooManyListenersException 
Register a new DragGestureListener.

Parameters:
dgl - the DragGestureListener to register with this DragGestureRecognizer.

Throws:
TooManyListenersException sample code for java.util.TooManyListenersException definition code for java.util.TooManyListenersException - if a DragGestureListener has already been added.

removeDragGestureListener sample code for java.awt.dnd.DragGestureRecognizer.removeDragGestureListener(java.awt.dnd.DragGestureListener) definition code for java.awt.dnd.DragGestureRecognizer.removeDragGestureListener(java.awt.dnd.DragGestureListener)

public void removeDragGestureListener(DragGestureListener sample code for java.awt.dnd.DragGestureListener definition code for java.awt.dnd.DragGestureListener  dgl)
unregister the current DragGestureListener

Parameters:
dgl - the DragGestureListener to unregister from this DragGestureRecognizer

Throws:
IllegalArgumentException - if dgl is not (equal to) the currently registered DragGestureListener.

fireDragGestureRecognized sample code for java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(int, java.awt.Point) definition code for java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(int, java.awt.Point)

protected void fireDragGestureRecognized(int dragAction,
                                         Point sample code for java.awt.Point definition code for java.awt.Point  p)
Notify the DragGestureListener that a Drag and Drop initiating gesture has occurred. Then reset the state of the Recognizer.

Parameters:
dragAction - The action initially selected by the users gesture
p - The point (in Component coords) where the gesture originated

appendEvent sample code for java.awt.dnd.DragGestureRecognizer.appendEvent(java.awt.event.InputEvent) definition code for java.awt.dnd.DragGestureRecognizer.appendEvent(java.awt.event.InputEvent)

protected void appendEvent(InputEvent sample code for java.awt.event.InputEvent definition code for java.awt.event.InputEvent  awtie)
Listeners registered on the Component by this Recognizer shall record all Events that are recognized as part of the series of Events that go to comprise a Drag and Drop initiating gesture via this API.

This method is used by a DragGestureRecognizer implementation to add an InputEvent subclass (that it believes is one in a series of events that comprise a Drag and Drop operation) to the array of events that this DragGestureRecognizer maintains internally.

Parameters:
awtie - the InputEvent to add to this DragGestureRecognizer's internal array of events. Note that null is not a valid value, and will be ignored.