public class DropTargetDragEvent extends DropTargetEvent
DropTargetDragEvent被输送到DropTargetListener经由其dragEnter事件()和的dragover()方法。
DropTargetDragEvent报告反映当前拖动操作状态的源放置操作和用户放置操作 。
源放置操作是DnDConstants的按位掩码,表示拖动操作支持的拖放操作的集合。
用户放置操作取决于拖动源支持的放置操作和用户选择的放置操作。 用户可以在拖动操作期间按修改键来选择放置操作:
Ctrl + Shift -> ACTION_LINK
Ctrl -> ACTION_COPY
Shift -> ACTION_MOVE
如果用户选择放置操作,则用户放置操作是DnDConstants中的一个,表示如果拖放源DnDConstants.ACTION_NONE此放置操作或DnDConstants.ACTION_NONE如果拖放源不支持此放置操作),则该操作将表示所选的放置操作。
如果用户没有选择降动作,一套DnDConstants表示设置拖动源支持的放置动作中搜索DnDConstants.ACTION_MOVE ,然后DnDConstants.ACTION_COPY ,然后为DnDConstants.ACTION_LINK和用户drop操作是找到的第一个常量。 如果没有找到常量,则用户删除操作是DnDConstants.ACTION_NONE 。
contextsource| Constructor and Description |
|---|
DropTargetDragEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions)
构造一个
DropTargetDragEvent给定
DropTargetContext的这个操作,位置的“拖”
Cursor的热点在
Component的坐标,用户放置操作和源放置操作。
|
| Modifier and Type | Method and Description |
|---|---|
void |
acceptDrag(int dragOperation)
接受拖动
|
DataFlavor[] |
getCurrentDataFlavors()
该方法返回当前
DataFlavor从S
DropTargetContext 。
|
List<DataFlavor> |
getCurrentDataFlavorsAsList()
此方法返回当前的
DataFlavor s作为
java.util.List
|
int |
getDropAction()
此方法返回用户放置操作。
|
Point |
getLocation()
该方法返回一个
Point表示
Cursor所述内的当前位置
Component'坐标。
|
int |
getSourceActions()
此方法返回源放置操作。
|
Transferable |
getTransferable()
此方法返回表示与当前拖动操作相关联的数据的Transferable对象。
|
boolean |
isDataFlavorSupported(DataFlavor df)
此方法返回
boolean指示是否支持
DataFlavor的DataFlavor。
|
void |
rejectDrag()
由于检查
dropAction或可用的
DataFlavor类型,拒绝拖动。
|
getDropTargetContextgetSource, toStringpublic DropTargetDragEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions)
DropTargetDragEvent给出了
DropTargetContext的这个操作,“拖”
Cursor的热点位置在
Component的坐标,用户放置操作和源放置操作。
dtc - 此操作的DropTargetContext
cursorLocn -
cursorLocn坐标中“拖动”光标的热点的位置
dropAction - 用户放弃操作
srcActions - 源丢弃操作
NullPointerException - 如果cursorLocn为null
IllegalArgumentException - 如果dropAction不是
DnDConstants 。
IllegalArgumentException -如果srcActions不是位掩码
DnDConstants 。
IllegalArgumentException - 如果dtc为
null 。
public Point getLocation()
Point表示
Cursor所述内的当前位置
Component'坐标。
Component的坐标。
public DataFlavor[] getCurrentDataFlavors()
DataFlavor从S
DropTargetContext 。
public List<DataFlavor> getCurrentDataFlavorsAsList()
DataFlavor作为
java.util.List
java.util.List当前的
DataFlavor小号
public boolean isDataFlavorSupported(DataFlavor df)
boolean指示是否支持
DataFlavor的DataFlavor。
df -
DataFlavor要测试
public int getSourceActions()
public int getDropAction()
public Transferable getTransferable()
InvalidDnDOperationException - 如果与拖动操作相关联的数据不可用
public void acceptDrag(int dragOperation)
DropTargetListeners dragEnter , dragOver和dropActionChanged方法如果实现希望如由表示为接受来自一个比由用户选择其他的srcActions操作dropAction 。
dragOperation - 目标接受的操作
public void rejectDrag()
dropAction or the available
DataFlavor types.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.