java.awt.dnd.DnDConstants#ACTION_COPY_OR_MOVE源码实例Demo

下面列出了java.awt.dnd.DnDConstants#ACTION_COPY_OR_MOVE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: DragDropUtilities.java
/** 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;
}
 
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();
}
 
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();
}
 
源代码4 项目: radiance   文件: AutoScrollingTreeDropTarget.java
AutoScrollingTreeDropTarget(JTree aTree, DropTargetListener listener) {
	super(aTree, DnDConstants.ACTION_COPY_OR_MOVE, listener);
	this.viewport = (JViewport) SwingUtilities.getAncestorOfClass(
			JViewport.class, aTree);
	this.scrollUnits = Math.max(aTree.getRowHeight(), 16);
	this.tree = aTree;
}
 
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();
}
 
源代码6 项目: Method_Trace_Tool   文件: Trace.java
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();
            }
        }
    });
}
 
源代码7 项目: netbeans   文件: WatchesNodeModel.java
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;
    }
}
 
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();
}
 
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() + 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();
}
 
源代码10 项目: dragonwell8_jdk   文件: SunDropTargetContextPeer.java
/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
 
源代码11 项目: ghidra   文件: DataTreeDragNDropHandler.java
@Override
public int getSupportedDragActions() {
	return DnDConstants.ACTION_COPY_OR_MOVE;
}
 
源代码12 项目: ghidra   文件: DataTypeDragNDropHandler.java
@Override
public int getSupportedDragActions() {
	return DnDConstants.ACTION_COPY_OR_MOVE;
}
 
源代码13 项目: TencentKona-8   文件: SunDropTargetContextPeer.java
/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
 
源代码14 项目: jdk8u60   文件: SunDropTargetContextPeer.java
/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
 
源代码15 项目: openjdk-jdk8u   文件: SunDropTargetContextPeer.java
/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
 
源代码16 项目: netbeans   文件: WatchesNodeModel.java
public int getAllowedDragActions() {
    return DnDConstants.ACTION_COPY_OR_MOVE;
}
 
/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
 
源代码18 项目: Bytecoder   文件: SunDropTargetContextPeer.java
/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
 
源代码19 项目: openjdk-jdk9   文件: SunDropTargetContextPeer.java
/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
 
源代码20 项目: jdk8u-jdk   文件: SunDropTargetContextPeer.java
/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}