当前位置: 首页>>代码示例>>Java>>正文


Java DnDConstants.ACTION_COPY_OR_MOVE属性代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:DragDropUtilities.java

示例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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:MissingEventsOnModalDialogTest.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:WatchesNodeModel.java

示例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();
            }
        }
    });
}
 
开发者ID:Harlber,项目名称:Method_Trace_Tool,代码行数:28,代码来源:Trace.java

示例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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:MissingEventsOnModalDialogTest.java

示例6: canImportHere

private boolean canImportHere(TransferHandler.TransferSupport info) {
	return
		((info.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0) &&
		info.isDataFlavorSupported(JDDLTransferData.DATA_FLAVOR);	
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:5,代码来源:JDragDropList.java

示例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;
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:5,代码来源:JDragDropList.java

示例8: getNodeAllowedActions

final int getNodeAllowedActions() {
    if( !isDnDActive && maybeExternalDnD )
        return DnDConstants.ACTION_COPY_OR_MOVE;
    
    return nodeAllowed;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:ExplorerDnDManager.java

示例9: getAllowedDragActions

public int getAllowedDragActions() {
    return DnDConstants.ACTION_COPY_OR_MOVE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:3,代码来源:WatchesNodeModel.java

示例10: setTargetActions

/**
 * @param actions set the current actions
 */

public synchronized void setTargetActions(int actions) {
    currentA = actions &
        (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:SunDropTargetContextPeer.java

示例11: configureDragAndDrop

public static void configureDragAndDrop(JTree tree, JTreeDragController controller) {
	tree.setAutoscrolls(true);
	new TreeTransferHandler(tree, controller, DnDConstants.ACTION_COPY_OR_MOVE, true);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:4,代码来源:JTreeUtil.java


注:本文中的java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。