本文整理汇总了Java中java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE属性的典型用法代码示例。如果您正苦于以下问题:Java DnDConstants.ACTION_COPY_OR_MOVE属性的具体用法?Java DnDConstants.ACTION_COPY_OR_MOVE怎么用?Java DnDConstants.ACTION_COPY_OR_MOVE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.dnd.DnDConstants
的用法示例。
在下文中一共展示了DnDConstants.ACTION_COPY_OR_MOVE属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNodeForAction
/** Utility method.
* @return true if given node supports given action,
* false otherwise.
*/
static boolean checkNodeForAction(Node node, int dragAction) {
if (
node.canCut() &&
((dragAction == DnDConstants.ACTION_MOVE) || (dragAction == DnDConstants.ACTION_COPY_OR_MOVE))
) {
return true;
}
if (
node.canCopy() &&
((dragAction == DnDConstants.ACTION_COPY) || (dragAction == DnDConstants.ACTION_COPY_OR_MOVE) ||
(dragAction == DnDConstants.ACTION_LINK) || (dragAction == DnDConstants.ACTION_REFERENCE))
) {
return true;
}
// hmmm, conditions not satisfied..
return false;
}
示例2: main
public static void main(String[] args) throws Exception {
Frame sourceFrame = createFrame("Source Frame", 0, 0);
Frame targetFrame = createFrame("Target Frame", 250, 250);
DragSource defaultDragSource
= DragSource.getDefaultDragSource();
defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame,
DnDConstants.ACTION_COPY_OR_MOVE,
new TestDragGestureListener());
new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE,
new TestDropTargetListener(targetFrame));
Robot robot = new Robot();
robot.setAutoDelay(50);
sourceFrame.toFront();
robot.waitForIdle();
Point point = getCenterPoint(sourceFrame);
robot.mouseMove(point.x, point.y);
robot.waitForIdle();
mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));
long time = System.currentTimeMillis() + 200;
while (!passed) {
if (time < System.currentTimeMillis()) {
sourceFrame.dispose();
targetFrame.dispose();
throw new RuntimeException("Mouse clicked event is lost!");
}
Thread.sleep(10);
}
sourceFrame.dispose();
targetFrame.dispose();
}
示例3: getAllowedDropActions
public int getAllowedDropActions(Transferable t) {
if (t != null && t.isDataFlavorSupported(new DataFlavor(Watch.class, null))) {
return DnDConstants.ACTION_COPY_OR_MOVE;
} else {
return DnDConstants.ACTION_COPY;
}
}
示例4: drag
public static void drag()//定义的拖拽方法
{
//panel表示要接受拖拽的控件
new DropTarget(JlPath, DnDConstants.ACTION_COPY_OR_MOVE, new DropTargetAdapter() {
public void drop(DropTargetDropEvent dtde)//重写适配器的drop方法
{
try {
if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor))//如果拖入的文件格式受支持
{
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);//接收拖拽来的数据
List<File> list = (List<File>) (dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor));
String temp = "";
for (File file : list) {
temp = file.getAbsolutePath();
JlPath.setText(temp);
break;
}
//JOptionPane.showMessageDialog(null, temp);
dtde.dropComplete(true);//指示拖拽操作已完成
} else {
dtde.rejectDrop();//否则拒绝拖拽来的数据
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
示例5: runTest
private static void runTest() throws Exception {
Frame sourceFrame = createFrame("Source Frame", 100, 100);
Frame targetFrame = createFrame("Target Frame", 350, 350);
DragSource defaultDragSource
= DragSource.getDefaultDragSource();
defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame,
DnDConstants.ACTION_COPY_OR_MOVE,
new TestDragGestureListener());
new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE,
new TestDropTargetListener(targetFrame));
Robot robot = new Robot();
robot.setAutoDelay(50);
sourceFrame.toFront();
robot.waitForIdle();
Point point = getCenterPoint(sourceFrame);
robot.mouseMove(point.x, point.y);
robot.waitForIdle();
mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));
long time = System.currentTimeMillis() + 1000;
while (!passed) {
if (time < System.currentTimeMillis()) {
sourceFrame.dispose();
targetFrame.dispose();
throw new RuntimeException("Mouse clicked event is lost!");
}
Thread.sleep(10);
}
sourceFrame.dispose();
targetFrame.dispose();
}
示例6: canImportHere
private boolean canImportHere(TransferHandler.TransferSupport info) {
return
((info.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0) &&
info.isDataFlavorSupported(JDDLTransferData.DATA_FLAVOR);
}
示例7: getSourceActions
@Override
public int getSourceActions(JComponent c) {
return DnDConstants.ACTION_COPY_OR_MOVE;
//return DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK | DnDConstants.ACTION_MOVE | DnDConstants.ACTION_REFERENCE;
}
示例8: getNodeAllowedActions
final int getNodeAllowedActions() {
if( !isDnDActive && maybeExternalDnD )
return DnDConstants.ACTION_COPY_OR_MOVE;
return nodeAllowed;
}
示例9: getAllowedDragActions
public int getAllowedDragActions() {
return DnDConstants.ACTION_COPY_OR_MOVE;
}
示例10: setTargetActions
/**
* @param actions set the current actions
*/
public synchronized void setTargetActions(int actions) {
currentA = actions &
(DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
示例11: configureDragAndDrop
public static void configureDragAndDrop(JTree tree, JTreeDragController controller) {
tree.setAutoscrolls(true);
new TreeTransferHandler(tree, controller, DnDConstants.ACTION_COPY_OR_MOVE, true);
}