當前位置: 首頁>>代碼示例>>Java>>正文


Java DnDConstants類代碼示例

本文整理匯總了Java中java.awt.dnd.DnDConstants的典型用法代碼示例。如果您正苦於以下問題:Java DnDConstants類的具體用法?Java DnDConstants怎麽用?Java DnDConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DnDConstants類屬於java.awt.dnd包,在下文中一共展示了DnDConstants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: executeDrop

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
@Override
public boolean executeDrop(JTree targetTree, Object draggedNode, Object targetNode, int action) {
	if (action == DnDConstants.ACTION_COPY) {
		return false;
	} else if (action == DnDConstants.ACTION_MOVE) {
		if (canMove(draggedNode, targetNode)) {
			if (draggedNode == targetNode)
				return true;
			listener.moveRequested(new Event(null), (AddTool) draggedNode, (AddTool) targetNode);
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:18,代碼來源:ProjectExplorer.java

示例2: ImageDragSource

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
ImageDragSource() {
    formats = retrieveFormatsToTest();
    passedArray = new boolean[formats.length];
    final DragSourceListener dsl = new DragSourceAdapter() {
        public void dragDropEnd(DragSourceDropEvent e) {
            System.err.println("Drop was successful=" + e.getDropSuccess());
            notifyTransferSuccess(e.getDropSuccess());
            if (++fi < formats.length) {
                leaveFormat(formats[fi]);
            }
        }
    };

    new DragSource().createDefaultDragGestureRecognizer(frame,
            DnDConstants.ACTION_COPY,
            dge -> dge.startDrag(null, new ImageSelection(image), dsl));
    leaveFormat(formats[fi]);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:ImageTransferTest.java

示例3: checkNodeForAction

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
/** 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,代碼行數:24,代碼來源:DragDropUtilities.java

示例4: testMoveItemAfter

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
/**
 * Test of moveItem method, of class org.netbeans.modules.palette.Category.
 */
public void testMoveItemAfter() throws IOException {
    PaletteActions actions = new DummyActions();
    PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), actions );
    Model model = pc.getModel();

    Category[] categories = model.getCategories();
    
    Category cat = categories[0];
    Item[] itemsBeforeMove = cat.getItems();
    
    Item source = itemsBeforeMove[0];
    Item target = itemsBeforeMove[itemsBeforeMove.length-1];
    
    cat.dropItem( createTransferable( source ), DnDConstants.ACTION_COPY_OR_MOVE, target, false );
    
    Item[] itemsAfterMove = cat.getItems();
    
    assertEquals( itemsBeforeMove.length, itemsAfterMove.length );
    assertEquals( source.getName(), itemsAfterMove[itemsAfterMove.length-1].getName() );
    assertEquals( itemsBeforeMove[1].getName(), itemsAfterMove[0].getName() );
    assertEquals( target.getName(), itemsAfterMove[itemsAfterMove.length-1-1].getName() );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:CategoryTest.java

示例5: testCanDropText

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
public void testCanDropText() throws Exception {
    PaletteActions actions = new DummyActions();
    PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), actions );
    Model model = pc.getModel();

    Category cat = model.getCategories()[0];
    
    DragAndDropHandler handler = new TextDragAndDropHandler();
    
    DataFlavor[] flavors = new DataFlavor[] { new DataFlavor( "text/xml" )  };
    assertTrue( handler.canDrop( cat.getLookup(), flavors, DnDConstants.ACTION_COPY_OR_MOVE ) );
    
    flavors = new DataFlavor[] { new DataFlavor( "text/html" )  };
    assertTrue( handler.canDrop( cat.getLookup(), flavors, DnDConstants.ACTION_COPY_OR_MOVE ) );
    
    flavors = new DataFlavor[] { new DataFlavor( "unsupported/mimetype" )  };
    assertFalse( handler.canDrop( cat.getLookup(), flavors, DnDConstants.ACTION_COPY_OR_MOVE ) );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:DragAndDropHandlerTest.java

示例6: initAndShowUI

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:MissingDragExitEventTest.java

示例7: mouseDragged

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
/**
 * Invoked when a mouse button is pressed on a component.
 */

public void mouseDragged(MouseEvent e) {
    if (!events.isEmpty()) { // gesture pending
        int dop = mapDragOperationFromModifiers(e);


        if (dop == DnDConstants.ACTION_NONE) {
            return;
        }

        MouseEvent trigger = (MouseEvent)events.get(0);

        Point      origin  = trigger.getPoint();
        Point      current = e.getPoint();

        int        dx      = Math.abs(origin.x - current.x);
        int        dy      = Math.abs(origin.y - current.y);

        if (dx > motionThreshold || dy > motionThreshold) {
            fireDragGestureRecognized(dop, ((MouseEvent)getTriggerEvent()).getPoint());
        } else
            appendEvent(e);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:XMouseDragGestureRecognizer.java

示例8: mapDragOperationFromModifiers

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
/**
 * determine the drop action from the event
 */

protected int mapDragOperationFromModifiers(MouseEvent e) {
    int mods = e.getModifiersEx();
    int btns = mods & ButtonMask;

    // Do not allow right mouse button drag since Motif DnD does not
    // terminate drag operation on right mouse button release.
    if (!(btns == InputEvent.BUTTON1_DOWN_MASK ||
          btns == InputEvent.BUTTON2_DOWN_MASK)) {
        return DnDConstants.ACTION_NONE;
    }

    return
        SunDragSourceContextPeer.convertModifiersToDropAction(mods,
                                                              getSourceActions());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:XMouseDragGestureRecognizer.java

示例9: mapDragOperationFromModifiers

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
/**
 * determine the drop action from the event
 */

protected int mapDragOperationFromModifiers(MouseEvent e) {
    int mods = e.getModifiersEx();
    int btns = mods & ButtonMask;

    // Prohibit multi-button drags.
    if (!(btns == InputEvent.BUTTON1_DOWN_MASK ||
          btns == InputEvent.BUTTON2_DOWN_MASK ||
          btns == InputEvent.BUTTON3_DOWN_MASK)) {
        return DnDConstants.ACTION_NONE;
    }

    return
        SunDragSourceContextPeer.convertModifiersToDropAction(mods,
                                                              getSourceActions());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:WMouseDragGestureRecognizer.java

示例10: drop

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    try {
        Transferable t = dtde.getTransferable();
        DataFlavor[] dataFlavors = t.getTransferDataFlavors();
        for (DataFlavor df : dataFlavors) {
            if (df.isFlavorJavaFileListType()) {
                File[] filesArray = (File[]) ((List<File>) t.getTransferData(df)).toArray();
                pathNameTextField.setText(getFilesName(filesArray));
            }
        }
    } catch (UnsupportedFlavorException e2) {
    } catch (IOException ex) {
        Logger.getLogger(SubtitleDownloaderUI.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:atulgpt,項目名稱:SubtitleDownloader,代碼行數:18,代碼來源:SubtitleDownloaderUI.java

示例11: mapOperation

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
/**
 * mapOperation
 */

private int mapOperation(int operation) {
    int[] operations = {
            DnDConstants.ACTION_MOVE,
            DnDConstants.ACTION_COPY,
            DnDConstants.ACTION_LINK,
    };
    int   ret = DnDConstants.ACTION_NONE;

    for (int i = 0; i < operations.length; i++) {
        if ((operation & operations[i]) == operations[i]) {
                ret = operations[i];
                break;
        }
    }

    return ret;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:SunDropTargetContextPeer.java

示例12: processXdndStatus

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
private boolean processXdndStatus(XClientMessageEvent xclient) {
    int action = DnDConstants.ACTION_NONE;

    /* Ignore XDnD messages from all other windows. */
    if (xclient.get_data(0) != getTargetWindow()) {
        return true;
    }

    if ((xclient.get_data(1) & XDnDConstants.XDND_ACCEPT_DROP_FLAG) != 0) {
        /* This feature is new in XDnD version 2, but we can use it as XDnD
           compliance only requires supporting version 3 and up. */
        action = XDnDConstants.getJavaActionForXDnDAction(xclient.get_data(4));
    }

    getProtocolListener().handleDragReply(action);

    return true;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:XDnDDragSourceProtocol.java

示例13: doUpdateTargetWindow

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
private void doUpdateTargetWindow(long subwindow, long time) {
    long clientWindow = 0;
    long proxyWindow = 0;
    XDragSourceProtocol protocol = null;
    boolean isReceiver = false;

    if (subwindow != 0) {
        clientWindow = findClientWindow(subwindow);
    }

    if (clientWindow != 0) {
        Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
        while (dragProtocols.hasNext()) {
            XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
            if (dragProtocol.attachTargetWindow(clientWindow, time)) {
                protocol = dragProtocol;
                break;
            }
        }
    }

    /* Update the global state. */
    dragProtocol = protocol;
    targetAction = DnDConstants.ACTION_NONE;
    targetRootSubwindow = subwindow;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:XDragSourceContextPeer.java

示例14: drop

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
public void drop(DropTargetDropEvent e)
{
	if (dragSource != null)
	{
		e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
		Point p = e.getLocation();
		int targetRow = rowAtPoint(p);

		Object edge = graph.insertEdge(null, null, null,
				dragSource.cell, JTableRenderer.this.cell, "sourceRow="
						+ sourceRow + ";targetRow=" + targetRow);
		graph.setSelectionCell(edge);

		// System.out.println("clearing drag source");
		dragSource = null;
		e.dropComplete(true);
	}
	else
	{
		e.rejectDrop();
	}
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:23,代碼來源:JTableRenderer.java

示例15: importData

import java.awt.dnd.DnDConstants; //導入依賴的package包/類
@Override
public boolean importData(TransferHandler.TransferSupport info) {
	if (!info.isDrop()) {
		return false;
	}
	if (!canImportHere(info)) {
		if (
			(JDragDropList.this.dropListener != null) &&
			JDragDropList.this.dropListener.acceptDrop(JDragDropList.this, info)
		) {
			return JDragDropList.this.dropListener.handleDrop(JDragDropList.this, info);
		} else {
			return false;
		}
	}

	JDDLTransferData<T> data = getData(info);
	int destIndex = JDragDropList.this.getDropLocation().getIndex();		
	
	/*
	System.err.print("[ ");
	for (int index : data.getIndices()) {
		System.err.print(index + " ");
	}
	System.err.print("] -> ");
	System.err.println(destIndex);
	*/
	 
	if ((info.getDropAction() & DnDConstants.ACTION_COPY) != 0) {
		copyItems(data.getSourceList(), JDragDropList.this, data.getValuesList(), destIndex);
	} else if ((info.getDropAction() & DnDConstants.ACTION_MOVE) != 0) {
		moveItems(data.getSourceList(), JDragDropList.this, data.getIndices(), destIndex);	
	} else {
		return false;
	}
	
	return true;
}
 
開發者ID:mgropp,項目名稱:pdfjumbler,代碼行數:39,代碼來源:JDragDropList.java


注:本文中的java.awt.dnd.DnDConstants類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。