當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。