所有类


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,并将其传递给在其单播传递事件源上注册为 DragGestureListenerDragGestureListener。此 DragGestureListener 负责使关联的 DragSource 开始 Drag 和 Drop 操作(如果合适)。

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

字段摘要
protected  Componentcomponent
          与此 DragGestureRecognizer 关联的 Component
protected  DragGestureListenerdragGestureListener
          与此 DragGestureRecognizer 关联的 DragGestureListener
protected  DragSourcedragSource
          与此 DragGestureRecognizer 关联的 DragSource
protected  ArrayList<InputEvent>events
          DragGestureRecognizer“识别”为触发拖动的“动作”事件列表(按顺序)。
protected  intsourceActions
          此 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
 
方法摘要
 voidaddDragGestureListener(DragGestureListener dgl)
          注册一个新的 DragGestureListener
protected  voidappendEvent(InputEvent awtie)
          Recognizer 在 Component 上注册的侦听器将通过此 API 记录所有识别的 Event,识别的 Event 是组成 Drag 和 Drop 开始动作的系列 Event 的一部分。
protected  voidfireDragGestureRecognized(int dragAction, Point p)
          通知 DragGestureListener 已发生了 Drag 和 Drop 开始动作。
 ComponentgetComponent()
          此方法返回 DragGestureRecognizer 所“观察”的Component,以便了解拖动开始动作。
 DragSourcegetDragSource()
          此方法返回 DragSource,为了进行 Drag 和 Drop 操作,将使用此 DragGestureRecognizer
 intgetSourceActions()
          此方法返回 Drag 和 Drop 操作所支持动作类型的 int 表示形式。
 InputEventgetTriggerEvent()
          此方法返回发起 Drag 和 Drop 操作的系列事件中的首个事件。
protected abstract  voidregisterListeners()
          向该 Component 注册此 DragGestureRecognizer 的 Listeners。
 voidremoveDragGestureListener(DragGestureListener dgl)
          取消注册当前的 DragGestureListener
 voidresetRecognizer()
          重置 Recognizer,如果 Recognizer 当前正在识别一个动作,则忽略。
 voidsetComponent(Component c)
          设置与该 DragGestureRecognizer 关联的 Component 使用此方法时还会调用 registerListeners() 和 unregisterListeners()。
 voidsetSourceActions(int actions)
          此方法设置此 Drag 和 Drop 操作允许的源拖动动作。
protected abstract  voidunregisterListeners()
          向该 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