Java 8 DropTargetEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DropTargetEvent class.

This code example shows how to use the following methods:acceptDrag, getCurrentDataFlavors, rejectDrag, getDropTargetContext
    private boolean actionSupported(int action) {
        return (action & (TransferHandler.COPY_OR_MOVE)) != TransferHandler.NONE;
    } 
 
    public void dragEnter(DropTargetDragEvent e) {
        DataFlavor[] flavors = e.getCurrentDataFlavors();
        DropTargetContext ctx = e.getDropTargetContext();
        JComponent c = (JComponent)ctx.getComponent();
        LimeTransferHandler handler = (LimeTransferHandler)c.getTransferHandler();
        DropDragInfo ddi = new DropDragInfo(e);
         
        if(handler != null && handler.canImport(c, flavors, ddi) && actionSupported(ddi.action))
            e.acceptDrag(ddi.action);
        else 
            e.rejectDrag();
    } 
 
    public void dragOver(DropTargetDragEvent e) {
        DataFlavor[] flavors = e.getCurrentDataFlavors();
        DropTargetContext ctx = e.getDropTargetContext();
6
CodeRank
This code example shows how to use the following methods:acceptDrop, getDropTargetContext
        //Transferable stuff = dtde.getTransferable(); 
         
        /* 
         * @todo check DataFlavor of stuff 
         */ 
        dtde.acceptDrop(DnDConstants.ACTION_MOVE);
 
        if (movingItems) {
            /* 
             * This is a local drag and drop to reorder items 
             */ 
            DnDListModel<T> model = getModel();
            model.moveItems(overIndex, dragIndices);
 
        } else { 
 
            // @todo stuff dragged from other list 
 
        } 
 

5
CodeRank
This code example shows how to use the following methods:getLocation, getDropTargetContext
		this.tree = tr;
		this.target = new DropTarget(tree, this);
	} 
 
	private AbstractDefineComponent getNodeForEvent(DropTargetDragEvent dtde) {
		Point p = dtde.getLocation();
		DropTargetContext dtc = dtde.getDropTargetContext();
		JTree tree = (JTree) dtc.getComponent();
		TreePath path = tree.getClosestPathForLocation(p.x, p.y);
		return (AbstractDefineComponent) path.getLastPathComponent();
	} 
 
	@Override 
	public void dragEnter(DropTargetDragEvent arg) {
 
		try { 
			Point p = arg.getLocation();
			TreePath path = tree.getPathForLocation(p.x, p.y);
			AnalyzedModuleComponent check = (AnalyzedModuleComponent) path
					.getLastPathComponent();
5
CodeRank
This code example shows how to use the following methods:getDropTargetContext
See Code Examples for Java 8 DropTargetEvent Methods: