当前位置: 首页>>代码示例>>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;未经允许,请勿转载。