Java Platform 1.2

java.awt.dnd
Class DragGestureRecognizer

java.lang.Object
  |
  +--java.awt.dnd.DragGestureRecognizer
Direct Known Subclasses:
MouseDragGestureRecognizer

public abstract class DragGestureRecognizer
extends Object

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 and drop action 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 and Drop action initiating gesture it will notify its unicast DragGestureListener by invoking its gestureRecognized() method.

See Also:
DragGestureListener, DragGestureEvent, DragSource

Field Summary
protected  Component component
           
protected  DragGestureListener dragGestureListener
           
protected  DragSource dragSource
           
protected  ArrayList events
           
protected  int sourceActions
           
 
Constructor Summary
protected DragGestureRecognizer(DragSource ds)
          construct a new DragGestureRecognizer
protected DragGestureRecognizer(DragSource ds, Component c)
          construct a new DragGestureRecognizer
protected DragGestureRecognizer(DragSource ds, Component c, int sa)
          construct a new DragGestureRecognizer
protected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl)
          construct a new DragGestureRecognizer
 
Method Summary
 void addDragGestureListener(DragGestureListener dgl)
          register a new DragGestureListener
protected  void appendEvent(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(int dragAction, Point p)
          notify the DragGestureListener that a Drag and Drop initiating gesture has occurred.
 Component getComponent()
           
 DragSource getDragSource()
           
 int getSourceActions()
           
 InputEvent getTriggerEvent()
           
protected abstract  void registerListeners()
          register this DragGestureRecognizer's Listeners with the Component subclasses must override this method
 void removeDragGestureListener(DragGestureListener dgl)
          unregister the current DragGestureListener
 void resetRecognizer()
          reset the Recognizer, if its currently recognizing a gesture, ignore it.
 void setComponent(Component c)
          set the Component that the DragGestureRecognizer is associated with registerListeners() and unregisterListeners() are called as a side effect as appropriate.
 void setSourceActions(int actions)
          set the permitted source drag actions
protected abstract  void unregisterListeners()
          unregister this DragGestureRecognizer's Listeners with the Component subclasses must override this method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dragSource

protected DragSource dragSource

component

protected Component component

dragGestureListener

protected DragGestureListener dragGestureListener

sourceActions

protected int sourceActions

events

protected ArrayList events
Constructor Detail

DragGestureRecognizer

protected DragGestureRecognizer(DragSource ds,
                                Component c,
                                int sa,
                                DragGestureListener dgl)
construct a new DragGestureRecognizer
Parameters:
ds - The DragSource for the Component c
c - The Component to observe
sa - The source drag actions
dgl - The DragGestureRecognizer to notify when a gesture is detected

DragGestureRecognizer

protected DragGestureRecognizer(DragSource ds,
                                Component c,
                                int sa)
construct a new DragGestureRecognizer
Parameters:
ds - The DragSource for the Component c
sa - The source drag actions
c - The Component to observe

DragGestureRecognizer

protected DragGestureRecognizer(DragSource ds,
                                Component c)
construct a new DragGestureRecognizer
Parameters:
ds - The DragSource for the Component c
c - The Component to observe

DragGestureRecognizer

protected DragGestureRecognizer(DragSource ds)
construct a new DragGestureRecognizer
Parameters:
ds - The DragSource for the Component c
Method Detail

registerListeners

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

unregisterListeners

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

getDragSource

public DragSource getDragSource()
Returns:
the DragSource

getComponent

public Component getComponent()
Returns:
The Component this DragGestureRecognizer is associated with

setComponent

public void setComponent(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

public int getSourceActions()
Returns:
the currently permitted source actions

setSourceActions

public void setSourceActions(int actions)
set the permitted source drag actions

getTriggerEvent

public InputEvent getTriggerEvent()
Returns:
the initial event that triggered the gesture

resetRecognizer

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

addDragGestureListener

public void addDragGestureListener(DragGestureListener dgl)
                            throws TooManyListenersException
register a new DragGestureListener

removeDragGestureListener

public void removeDragGestureListener(DragGestureListener dgl)
unregister the current DragGestureListener

fireDragGestureRecognized

protected void fireDragGestureRecognized(int dragAction,
                                         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

protected void appendEvent(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 state is cleared when a the gesture is completed, after the DragGestureListener is notified.

Java Platform 1.2

Submit a bug or feature Version 1.2 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.