JavaTM 2 Platform
Standard Ed. 6

java.awt.dnd
类 DragGestureRecognizer

java.lang.Object
  继承者 java.awt.dnd.DragGestureRecognizer
所有已实现的接口:
Serializable
直接已知子类:
MouseDragGestureRecognizer

public abstract class DragGestureRecognizer
extends Object
implements Serializable

DragGestureRecognizer 是一个针对与平台相关的侦听器规范的抽象基类,它可以与特定 Component 关联以标识与平台相关的拖动开始动作。

可从与特定 Component 关联的 DragSource,或通过其 createDragGestureRecognizer() 方法从 Toolkit 对象获得合适的 DragGestureRecognizer 子类。

DragGestureRecognizer 一旦与特定的 Component 关联,就会在该 Component 上注册合适的侦听器接口,以跟踪传递给该 Component 的输入事件。

DragGestureRecognizer 一旦将该 Component 上的事件顺序标识为拖动开始动作,它就会通过调用其 gestureRecognized() 方法来通知其单播传递的 DragGestureListener

当具体的 DragGestureRecognizer 实例在其关联的 Component 上检测到拖动开始动作时,它将激发一个 DragGestureEvent,并针对 DragGestureListener 事件将其传递给在其单播传递事件源上注册的 DragGestureListener。此 DragGestureListener 负责使关联的 DragSource 开始 Drag 和 Drop 操作(如果合适)。

另请参见:
DragGestureListener, DragGestureEvent, DragSource, 序列化表格

字段摘要
protected  Component component
          与此 DragGestureRecognizer 关联的 Component
protected  DragGestureListener dragGestureListener
          与此 DragGestureRecognizer 关联的 DragGestureListener
protected  DragSource dragSource
          与此 DragGestureRecognizer 关联的 DragSource
protected  ArrayList<InputEvent> events
          DragGestureRecognizer“识别”为触发拖动的“动作”事件列表(按顺序)。
protected  int sourceActions
          此 Drag 和 Drop 操作中所用动作类型的 int 表示形式。
 
构造方法摘要
protected DragGestureRecognizer(DragSource ds)
          构造一个新的 DragGestureRecognizer,使其具有给定此 Drag 和 Drop 操作中使用的 DragSource
protected DragGestureRecognizer(DragSource ds, Component c)
          构造一个新的 DragGestureRecognizer,使其具有给定此 Drag 和 Drop 操作中使用的 DragSource 和此 DragGestureRecognizer 应该“观察”拖动开始动作的 Component
protected DragGestureRecognizer(DragSource ds, Component c, int sa)
          构造一个新的 DragGestureRecognizer,使其具有给定此 Drag 和 Drop 操作中使用的 DragSource、此 DragGestureRecognizer 应该“观察”拖动开始动作的 Component 和此 Drag 和 Drop 操作所支持的动作。
protected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl)
          构造一个新的 DragGestureRecognizer,使其具有给定此 Drag 和 Drop 操作中使用的 DragSource、此 DragGestureRecognizer 应该“观察”拖动开始动作的 Component、此 Drag 和 Drop 操作所支持的操作和一旦检测到拖动开始动作要通知的 DragGestureListener
 
方法摘要
 void addDragGestureListener(DragGestureListener dgl)
          注册一个新的 DragGestureListener
protected  void appendEvent(InputEvent awtie)
          Recognizer 在 Component 上注册的侦听器将通过此 API 记录所有识别的 Event,识别的 Event 是组成 Drag 和 Drop 开始动作的系列 Event 的一部分。
protected  void fireDragGestureRecognized(int dragAction, Point p)
          通知 DragGestureListener 已发生了 Drag 和 Drop 开始动作。
 Component getComponent()
          此方法返回 DragGestureRecognizer 所“观察”的 Component,以便了解拖动开始动作。
 DragSource getDragSource()
          此方法返回 DragSource,为了进行 Drag 和 Drop 操作,将使用此 DragGestureRecognizer
 int getSourceActions()
          此方法返回 Drag 和 Drop 操作所支持动作类型的 int 表示形式。
 InputEvent getTriggerEvent()
          此方法返回发起 Drag 和 Drop 操作的系列事件中的首个事件。
protected abstract  void registerListeners()
          向该 Component 注册此 DragGestureRecognizer 的 Listeners。
 void removeDragGestureListener(DragGestureListener dgl)
          取消注册当前的 DragGestureListener
 void resetRecognizer()
          重置 Recognizer,如果 Recognizer 当前正在识别一个动作,则忽略。
 void setComponent(Component c)
          设置与该 DragGestureRecognizer 关联的 Component 使用此方法时还会调用 registerListeners() 和 unregisterListeners()。
 void setSourceActions(int actions)
          此方法设置此 Drag 和 Drop 操作允许的源拖动动作。
protected abstract  void unregisterListeners()
          向该 Component 取消注册此 DragGestureRecognizer 的 Listeners。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

dragSource

protected DragSource dragSource
与此 DragGestureRecognizer 关联的 DragSource


component

protected Component component
与此 DragGestureRecognizer 关联的 Component


dragGestureListener

protected transient DragGestureListener dragGestureListener
与此 DragGestureRecognizer 关联的 DragGestureListener


sourceActions

protected int sourceActions
此 Drag 和 Drop 操作中所用动作类型的 int 表示形式。


events

protected ArrayList<InputEvent> events
DragGestureRecognizer“识别”为触发拖动的“动作”事件列表(按顺序)。

构造方法详细信息

DragGestureRecognizer

protected DragGestureRecognizer(DragSource ds,
                                Component c,
                                int sa,
                                DragGestureListener dgl)
构造一个新的 DragGestureRecognizer,使其具有给定此 Drag 和 Drop 操作中使用的 DragSource、此 DragGestureRecognizer 应该“观察”拖动开始动作的 Component、此 Drag 和 Drop 操作所支持的操作和一旦检测到拖动开始动作要通知的 DragGestureListener

参数:
ds - 此 DragGestureRecognizer 用于处理 Drag 和 Drop 操作的 DragSource
c - 为了检测拖动开始动作,此 DragGestureRecognizer 应该“观察”事件流去往的 Component。如果此值为 null,则 DragGestureRecognizer 未与任何 Component 关联。
sa - 此 Drag 和 Drop 操作支持的 DnDConstants 集合(逻辑“或”)
dgl - 检测到拖动动作时要通知的 DragGestureRecognizer

抛出:
IllegalArgumentException - 如果 ds 为 null

DragGestureRecognizer

protected DragGestureRecognizer(DragSource ds,
                                Component c,
                                int sa)
构造一个新的 DragGestureRecognizer,使其具有给定此 Drag 和 Drop 操作中使用的 DragSource、此 DragGestureRecognizer 应该“观察”拖动开始动作的 Component 和此 Drag 和 Drop 操作所支持的动作。

参数:
ds - 此 DragGestureRecognizer 用于处理 Drag 和 Drop 操作的 DragSource
c - 为了检测拖动开始动作,此 DragGestureRecognizer 应该“观察”事件流去往的 Component。如果此值为 null,则 DragGestureRecognizer 未与任何 Component 关联。
sa - 此 Drag 和 Drop 操作支持的 DnDConstants 集合(逻辑“或”)

抛出:
IllegalArgumentException - 如果 ds 为 null

DragGestureRecognizer

protected DragGestureRecognizer(DragSource ds,
                                Component c)
构造一个新的 DragGestureRecognizer,使其具有给定此 Drag 和 Drop 操作中使用的 DragSource 和此 DragGestureRecognizer 应该“观察”拖动开始动作的 Component

参数:
ds - 此 DragGestureRecognizer 用于处理 Drag 和 Drop 操作的 DragSource
c - 为了检测拖动开始动作,此 DragGestureRecognizer 应该“观察”事件流去往的 Component。如果此值为 null,则 DragGestureRecognizer 未与任何 Component 关联。

抛出:
IllegalArgumentException - 如果 ds 为 null

DragGestureRecognizer

protected DragGestureRecognizer(DragSource ds)
构造一个新的 DragGestureRecognizer,使其具有给定此 Drag 和 Drop 操作中使用的 DragSource

参数:
ds - 此 DragGestureRecognizer 用于处理 Drag 和 Drop 操作的 DragSource

抛出:
IllegalArgumentException - 如果 ds 为 null
方法详细信息

registerListeners

protected abstract void registerListeners()
向该 Component 注册此 DragGestureRecognizer 的 Listeners。子类必须重写此方法


unregisterListeners

protected abstract void unregisterListeners()
向该 Component 取消注册此 DragGestureRecognizer 的 Listeners。子类必须重写此方法


getDragSource

public DragSource getDragSource()
此方法返回 DragSource,为了进行 Drag 和 Drop 操作,将使用此 DragGestureRecognizer

返回:
DragSource

getComponent

public Component getComponent()
此方法返回 DragGestureRecognizer 所“观察”的 Component,以便了解拖动开始动作。

返回:
与此 DragGestureRecognizer 关联的 Component

setComponent

public void setComponent(Component c)
设置与该 DragGestureRecognizer 关联的 Component 使用此方法时还会调用 registerListeners() 和 unregisterListeners()。

参数:
c - Componentnull

getSourceActions

public int getSourceActions()
此方法返回 Drag 和 Drop 操作所支持动作类型的 int 表示形式。

返回:
当前允许的源动作

setSourceActions

public void setSourceActions(int actions)
此方法设置此 Drag 和 Drop 操作允许的源拖动动作。

参数:
actions - 允许的源拖动动作

getTriggerEvent

public InputEvent getTriggerEvent()
此方法返回发起 Drag 和 Drop 操作的系列事件中的首个事件。

返回:
触发拖动动作的初始事件

resetRecognizer

public void resetRecognizer()
重置 Recognizer,如果 Recognizer 当前正在识别一个动作,则忽略。


addDragGestureListener

public void addDragGestureListener(DragGestureListener dgl)
                            throws TooManyListenersException
注册一个新的 DragGestureListener

参数:
dgl - 使用此 DragGestureRecognizer 注册的 DragGestureListener

抛出:
TooManyListenersException - 如果已经添加了 DragGestureListener

removeDragGestureListener

public void removeDragGestureListener(DragGestureListener dgl)
取消注册当前的 DragGestureListener

参数:
dgl - 使用此 DragGestureRecognizer 取消注册的 DragGestureListener

抛出:
IllegalArgumentException - 如果 dgl 不是(等于)当前已注册的 DragGestureListener

fireDragGestureRecognized

protected void fireDragGestureRecognized(int dragAction,
                                         Point p)
通知 DragGestureListener 已发生了 Drag 和 Drop 开始动作。然后重置 Recognizer 的状态。

参数:
dragAction - 通过用户动作初始选中的动作
p - 该动作开始的 point(在 Component 坐标中)

appendEvent

protected void appendEvent(InputEvent awtie)
Recognizer 在 Component 上注册的侦听器将通过此 API 记录所有识别的 Event,识别的 Event 是组成 Drag 和 Drop 开始动作的系列 Event 的一部分。

DragGestureRecognizer 实现使用此方法将 InputEvent 子类(相信它是组成 Drag 和 Drop 操作的系列事件的一部分)添加到此 DragGestureRecognizer 内部维护的事件数组中。

参数:
awtie - 添加到此 DragGestureRecognizer 内部事件数组的 InputEvent。注意,null 不是有效值,将忽略该值。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only