java.lang.Object
java.awt.dnd.DragGestureRecognizer
- 所有已实现的接口:
-
Serializable
- 直接已知的子类:
-
MouseDragGestureRecognizer
DragGestureRecognizer 是用于指定与特定 Component 关联的平台相关侦听器的抽象基类,以识别平台相关的拖动启动手势。
适当的 DragGestureRecognizer 子类实例是从与特定 Component 关联的 DragSource 或通过其 createDragGestureRecognizer() 方法从 Toolkit 对象获取的。
一旦 DragGestureRecognizer 与特定 Component 关联,它将在该 Component 上注册适当的侦听器接口,以跟踪传递给 Component 的输入事件。
一旦 DragGestureRecognizer 将 Component 上的事件序列识别为拖动启动手势,它将通过调用其单播 DragGestureListener 的 gestureRecognized() 方法来通知它。
当具体的 DragGestureRecognizer 实例在其关联的 Component 上检测到拖动启动手势时,它会向其单播事件源上注册的 DragGestureListener 触发 DragGestureListener 事件。这个 DragGestureListener 负责导致关联的 DragSource 启动拖放操作(如果适用)。
- 参见:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Component与此DragGestureRecognizer关联的Component。protected DragGestureListener与此DragGestureRecognizer关联的DragGestureListener。protected DragSource与此DragGestureRecognizer关联的DragSource。protected ArrayList<InputEvent> DragGestureRecognizer"识别"为触发拖动的手势的事件列表(按顺序)。protected int代表此拖放操作中使用的操作类型的int。 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected给定用于此拖放操作的DragSource构造一个新的DragGestureRecognizer。protected给定用于此拖放操作的DragSource,以及此DragGestureRecognizer应该“观察”以检测拖动启动手势的Component,构造一个新的DragGestureRecognizer。protectedDragGestureRecognizer(DragSource ds, Component c, int sa) 给定用于此拖放操作的DragSource,此DragGestureRecognizer应该“观察”以检测拖动启动手势的Component,以及此拖放操作支持的操作类型,构造一个新的DragGestureRecognizer。protectedDragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl) 给定用于此拖放操作的DragSource,此DragGestureRecognizer应该“观察”以检测拖动启动手势的Component,此拖放操作支持的操作类型,以及一旦检测到拖动启动手势就通知的DragGestureListener,构造一个新的DragGestureRecognizer。 -
Method Summary
Modifier and TypeMethodDescriptionvoid注册一个新的DragGestureListener。protected voidappendEvent(InputEvent awtie) 由此 Recognizer 在 Component 上注册的侦听器应记录所有被识别为组成拖放启动手势系列事件的事件。protected voidfireDragGestureRecognized(int dragAction, Point p) 通知 DragGestureListener 发生了拖放启动手势。此方法返回DragGestureRecognizer用于检测拖动启动手势的“观察”Component。此方法返回此DragGestureRecognizer将用于处理拖放操作的DragSource。int此方法返回一个表示此拖放操作将支持的操作类型的 int。此方法返回启动拖放操作的事件系列中的第一个事件。protected abstract void注册此 DragGestureRecognizer 的 Listeners 到 Component,子类必须重写此方法。void注销当前的 DragGestureListener。void重置 Recognizer,如果当前正在识别手势,则忽略它。void设置 DragGestureRecognizer 关联的 Component,根据需要调用 registerListeners() 和 unregisterListeners()。voidsetSourceActions(int actions) 此方法设置此拖放操作的允许源拖动操作类型。protected abstract void注销此 DragGestureRecognizer 的 Listeners 与 Component,子类必须重写此方法。
-
Field Details
-
dragSource
与此DragGestureRecognizer关联的DragSource。 -
component
与此DragGestureRecognizer关联的Component。 -
dragGestureListener
与此DragGestureRecognizer关联的DragGestureListener。 -
sourceActions
protected int sourceActions代表此拖放操作中使用的操作类型的int。 -
events
DragGestureRecognizer“识别”为触发拖动的手势的事件列表(按顺序)。
-
-
Constructor Details
-
DragGestureRecognizer
给定用于此拖放操作的DragSource,此DragGestureRecognizer应该“观察”以检测拖动启动手势的Component,此拖放操作支持的操作类型,以及一旦检测到拖动启动手势就通知的DragGestureListener,构造一个新的DragGestureRecognizer。- 参数:
-
ds- 此DragGestureRecognizer将用于处理拖放操作的DragSource -
c- 此DragGestureRecognizer应该“观察”事件流以检测拖动启动手势的Component。如果此值为null,则DragGestureRecognizer不与任何Component关联。 -
sa- 此拖放操作将支持的DnDConstants的集合(逻辑 OR)。 -
dgl- 当检测到拖动手势时通知的DragGestureRecognizer。 - 抛出:
-
IllegalArgumentException- 如果 ds 为null。
-
DragGestureRecognizer
给定用于此拖放操作的DragSource,此DragGestureRecognizer应该“观察”以检测拖动启动手势的Component,以及此拖放操作支持的操作类型,构造一个新的DragGestureRecognizer。- 参数:
-
ds- 此DragGestureRecognizer将用于处理拖放操作的DragSource -
c- 此DragGestureRecognizer应该“观察”事件流以检测拖动启动手势的Component。如果此值为null,则DragGestureRecognizer不与任何Component关联。 -
sa- 此拖放操作将支持的DnDConstants的集合(逻辑 OR)。 - 抛出:
-
IllegalArgumentException- 如果 ds 为null。
-
DragGestureRecognizer
给定用于此拖放操作的DragSource,以及此DragGestureRecognizer应该“观察”以检测拖动启动手势的Component,构造一个新的DragGestureRecognizer。- 参数:
-
ds- 此DragGestureRecognizer将用于处理拖放操作的DragSource -
c- 此DragGestureRecognizer应该“观察”事件流以检测拖动启动手势的Component。如果此值为null,则DragGestureRecognizer不与任何Component关联。 - 抛出:
-
IllegalArgumentException- 如果 ds 为null。
-
DragGestureRecognizer
给定用于此拖放操作的DragSource,构造一个新的DragGestureRecognizer。- 参数:
-
ds- 此DragGestureRecognizer将用于处理拖放操作的DragSource - 抛出:
-
IllegalArgumentException- 如果 ds 为null。
-
-
Method Details
-
registerListeners
protected abstract void registerListeners()注册此 DragGestureRecognizer 的 Listeners 到 Component,子类必须重写此方法。 -
unregisterListeners
protected abstract void unregisterListeners()注销此 DragGestureRecognizer 的 Listeners 与 Component,子类必须重写此方法。 -
getDragSource
此方法返回此DragGestureRecognizer将用于处理拖放操作的DragSource。- 返回:
- DragSource
-
getComponent
该方法返回由DragGestureRecognizer用于拖动启动手势的“观察”Component。- 返回:
- 与此DragGestureRecognizer关联的Component
-
setComponent
设置DragGestureRecognizer关联的Component,根据需要调用registerListeners()和unregisterListeners()。- 参数:
-
c- Component或null
-
getSourceActions
public int getSourceActions()该方法返回表示此拖放操作将支持的操作类型的int。- 返回:
- 当前允许的源操作
-
setSourceActions
public void setSourceActions(int actions) 该方法设置此拖放操作的允许源拖动操作。- 参数:
-
actions- 允许的源拖动操作
-
getTriggerEvent
该方法返回启动拖放操作的事件系列中的第一个事件。- 返回:
- 触发拖动手势的初始事件
-
resetRecognizer
public void resetRecognizer()重置Recognizer,如果当前正在识别手势,则忽略它。 -
addDragGestureListener
注册一个新的DragGestureListener。- 参数:
-
dgl- 要注册到此DragGestureRecognizer的DragGestureListener。 - 抛出:
-
TooManyListenersException- 如果已经添加了DragGestureListener。
-
removeDragGestureListener
注销当前的DragGestureListener- 参数:
-
dgl- 要从此DragGestureRecognizer注销的DragGestureListener - 抛出:
-
IllegalArgumentException- 如果dgl不等于当前注册的DragGestureListener。
-
fireDragGestureRecognized
通知DragGestureListener发生了拖放启动手势。然后重置Recognizer的状态。- 参数:
-
dragAction- 用户手势最初选择的操作 -
p- 手势起始点(在Component坐标中)
-
appendEvent
由此Recognizer在Component上注册的Listeners应记录所有被识别为组成拖放启动手势系列事件的事件。通过此API。此方法由
DragGestureRecognizer实现使用,将InputEvent子类(它认为是组成拖放操作的事件系列之一)添加到此DragGestureRecognizer内部维护的事件数组中。- 参数:
-
awtie- 要添加到此DragGestureRecognizer内部事件数组的InputEvent。请注意,null不是有效值,将被忽略。
-