public abstract class DragGestureRecognizer extends Object implements Serializable
DragGestureRecognizerは、プラットフォーム依存のドラッグ開始ジェスチャを識別するために特定のComponentに関連付けることのできる、プラットフォーム依存のリスナーを指定するための抽象基底クラスです。
適切なDragGestureRecognizerサブクラス・インスタンスは、特定のComponentに関連付けられたDragSourceから、またはそのcreateDragGestureRecognizer()メソッド経由でToolkitオブジェクトから取得されます。
DragGestureRecognizerは、特定のComponentに関連付けられると、Componentに送られる入力イベントを追跡するために、そのComponentに適切なリスナー・インタフェースを登録します。
DragGestureRecognizerは、Component上のイベントのシーケンスをドラッグ開始ジェスチャとして識別すると、gestureRecognized()メソッドを呼び出すことによってそのユニキャストDragGestureListenerに通知します。
具象DragGestureRecognizerインスタンスは、関連付けられているComponent上のドラッグ開始ジェスチャを検出すると、DragGestureListenerイベントのユニキャスト・イベント・ソースに登録されているDragGestureListenerに対してDragGestureEventをトリガーします。 このDragGestureListenerは、関連付けられたDragSourceに(必要に応じて)ドラッグ&ドロップ操作の開始を促します。
| 修飾子と型 | フィールド | 説明 |
|---|---|---|
protected Component |
component |
この
DragGestureRecognizerに関連付けられているComponent。 |
protected DragGestureListener |
dragGestureListener |
この
DragGestureRecognizerに関連付けられているDragGestureListener。 |
protected DragSource |
dragSource |
この
DragGestureRecognizerに関連付けられているDragSource。 |
protected ArrayList<InputEvent> |
events |
ドラッグをトリガーする「ジェスチャ」として
DragGestureRecognizerによって「認識」された(順番に並べられた)イベントのリスト。 |
protected int |
sourceActions |
このドラッグ&ドロップ操作で使用されるアクションのタイプを表す
int。 |
| 修飾子 | コンストラクタ | 説明 |
|---|---|---|
protected |
DragGestureRecognizer(DragSource ds) |
このドラッグ&ドロップ操作で使用される
DragSourceを使用して、新しいDragGestureRecognizerを構築します。 |
protected |
DragGestureRecognizer(DragSource ds, Component c) |
このドラッグ&ドロップ操作で使用される
DragSource、およびこのDragGestureRecognizerがドラッグ開始ジェスチャを「監視」すべきComponentを使用して、新しいDragGestureRecognizerを構築します。 |
protected |
DragGestureRecognizer(DragSource ds, Component c, int sa) |
このドラッグ&ドロップ操作で使用される
DragSource、このDragGestureRecognizerがドラッグ開始ジェスチャを「監視」すべきComponent、およびこのドラッグ&ドロップ操作でサポートされるアクションを使用して、新しいDragGestureRecognizerを構築します。 |
protected |
DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl) |
このドラッグ&ドロップ操作で使用される
DragSource、このDragGestureRecognizerがドラッグ開始ジェスチャを「監視」すべきComponent、このドラッグ&ドロップ操作でサポートされるアクション、およびドラッグ開始ジェスチャが検出されたときに通知するDragGestureListenerを使用して、新しいDragGestureRecognizerを構築します。 |
| 修飾子と型 | メソッド | 説明 |
|---|---|---|
void |
addDragGestureListener(DragGestureListener dgl) |
新しい
DragGestureListenerを登録します。 |
protected void |
appendEvent(InputEvent awtie) |
このRecognizerによってComponentで登録されたリスナーは、このAPIを介して、ドラッグ&ドロップ開始ジェスチャを構成する一連のイベントの一部として認識されるすべてのイベントを記録します。
|
protected void |
fireDragGestureRecognized(int dragAction, Point p) |
ドラッグ&ドロップ開始ジェスチャが発生したことをDragGestureListenerに通知します。
|
Component |
getComponent() |
このメソッドは、
DragGestureRecognizerによってドラッグ開始ジェスチャを「監視」されるComponentを返します。 |
DragSource |
getDragSource() |
このメソッドは、この
DragGestureRecognizerがドラッグ&ドロップ操作を処理するために使用するDragSourceを返します。 |
int |
getSourceActions() |
このメソッドは、このドラッグ&ドロップ操作がサポートするアクションの形式を表すintを返します。
|
InputEvent |
getTriggerEvent() |
このメソッドは、ドラッグ&ドロップ操作を開始した一連のイベントの最初のイベントを返します。
|
protected abstract void |
registerListeners() |
このDragGestureRecognizerのリスナーをComponentに登録します。サブクラスはこのメソッドをオーバーライドする必要があります。
|
void |
removeDragGestureListener(DragGestureListener dgl) |
現在のDragGestureListenerの登録を解除します。
|
void |
resetRecognizer() |
Recognizerを取り消します。現在ジェスチャを認識している場合は無視されます。
|
void |
setComponent(Component c) |
DragGestureRecognizerが関連付けられるComponentを設定します。registerListeners()およびunregisterListeners()は、必要に応じて副作用として呼び出されます。
|
void |
setSourceActions(int actions) |
このメソッドはドラッグ&ドロップ操作に許可されているソース・ドラッグ・アクションを設定します。
|
protected abstract void |
unregisterListeners() |
このDragGestureRecognizerのリスナーをComponentから登録解除します。サブクラスはこのメソッドをオーバーライドする必要があります。
|
protected DragSource dragSource
DragGestureRecognizerに関連付けられているDragSource。protected Component component
DragGestureRecognizerに関連付けられているComponent。protected transient DragGestureListener dragGestureListener
DragGestureRecognizerに関連付けられているDragGestureListener。protected int sourceActions
int。protected ArrayList<InputEvent> events
DragGestureRecognizerによって「認識」された(順番に並べられた)イベントのリスト。protected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl)
DragSource、このDragGestureRecognizerがドラッグ開始ジェスチャを「監視」すべきComponent、このドラッグ&ドロップ操作でサポートされるアクション、およびドラッグ開始ジェスチャが検出されたときに通知するDragGestureListenerを使用して、新しいDragGestureRecognizerを構築します。
ds - このDragGestureRecognizerがドラッグ&ドロップ操作を処理するために使用するDragSourcec - このDragGestureRecognizerがドラッグ開始ジェスチャを検出するために、イベント・ストリームの宛先として「監視」するComponent。 この値がnullの場合、DragGestureRecognizerはどのComponentにも関連付けられません。 sa - このドラッグ&ドロップ操作がサポートするDnDConstantsのセット(論理和)dgl - ドラッグ・ジェスチャが検出されたときに通知するDragGestureRecognizer
IllegalArgumentException - dsがnullの場合。protected DragGestureRecognizer(DragSource ds, Component c, int sa)
DragSource、このDragGestureRecognizerがドラッグ開始ジェスチャを「監視」すべきComponent、およびこのドラッグ&ドロップ操作でサポートされるアクションを使用して、新しいDragGestureRecognizerを構築します。
ds - このDragGestureRecognizerがドラッグ&ドロップ操作を処理するために使用するDragSourcec - このDragGestureRecognizerがドラッグ開始ジェスチャを検出するために、イベント・ストリームの宛先として「監視」するComponent。 この値がnullの場合、DragGestureRecognizerはどのComponentにも関連付けられません。 sa - このドラッグ&ドロップ操作がサポートするDnDConstantsのセット(論理和)
IllegalArgumentException - dsがnullの場合。protected DragGestureRecognizer(DragSource ds, Component c)
DragSource、およびこのDragGestureRecognizerがドラッグ開始ジェスチャを「監視」すべきComponentを使用して、新しいDragGestureRecognizerを構築します。
ds - このDragGestureRecognizerがドラッグ&ドロップ操作を処理するために使用するDragSourcec - このDragGestureRecognizerがドラッグ開始ジェスチャを検出するために、イベント・ストリームの宛先として「監視」するComponent。 この値がnullの場合、DragGestureRecognizerはどのComponentにも関連付けられません。
IllegalArgumentException - dsがnullの場合。protected DragGestureRecognizer(DragSource ds)
DragSourceを使用して、新しいDragGestureRecognizerを構築します。
ds - このDragGestureRecognizerがドラッグ&ドロップ操作を処理するために使用するDragSource
IllegalArgumentException - dsがnullの場合。protected abstract void registerListeners()
protected abstract void unregisterListeners()
public DragSource getDragSource()
DragGestureRecognizerがドラッグ&ドロップ操作を処理するために使用するDragSourceを返します。
public Component getComponent()
DragGestureRecognizerによってドラッグ開始ジェスチャを「監視」されるComponentを返します。
public void setComponent(Component c)
c - Componentまたはnullpublic int getSourceActions()
public void setSourceActions(int actions)
actions - 許可されているソース・ドラッグ・アクションpublic InputEvent getTriggerEvent()
public void resetRecognizer()
public void addDragGestureListener(DragGestureListener dgl) throws TooManyListenersException
DragGestureListenerを登録します。
dgl - このDragGestureRecognizerに登録するDragGestureListener。
TooManyListenersException - DragGestureListenerがすでに追加されている場合。public void removeDragGestureListener(DragGestureListener dgl)
dgl - このDragGestureRecognizerから登録解除するDragGestureListener
IllegalArgumentException - dglが現在登録されているDragGestureListenerではない(異なる)場合。protected void fireDragGestureRecognized(int dragAction,
Point p)
dragAction - ユーザー・ジェスチャによって最初に選択されたアクションp - ジェスチャが発生したポイント(Component座標内)protected void appendEvent(InputEvent awtie)
このメソッドは、DragGestureRecognizer実装が(ドラッグ&ドロップ操作を構成する一連のイベントのうちの1つであると見なしている) InputEventサブクラスを、このDragGestureRecognizerが内部的に保持しているイベントの配列に追加するために使用します。
awtie - このDragGestureRecognizerの内部のイベント配列に追加するInputEvent。 nullは有効な値ではなく、無視されることに注意。 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。