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


Java DropTargetDropEvent.acceptDrop方法代碼示例

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


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

示例1: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent e) {
    Collection<? extends ExternalDropHandler> handlers = Lookup.getDefault().lookupAll(ExternalDropHandler.class);
    for (ExternalDropHandler handler : handlers) {
        if (handler.canDrop(e)) {
            e.acceptDrop(DnDConstants.ACTION_COPY);
            boolean dropped = handler.handleDrop(e);
            if(!dropped) {
                continue; //try next ExternalDropHandler
            }
            e.dropComplete(true);
            isDragging = false;
            return;
        }
    }
    orig.drop(e);
    isDragging = false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:QuietEditorPane.java

示例2: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的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

示例3: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的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

示例4: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的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,代碼行數:18,代碼來源:JTableRenderer.java

示例5: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
    if (checkDropValid()) {
        int action = dtde.getDropAction();
        
        ProjectHandler project = ProjectHandler.getInstance();
        if (action == DnDConstants.ACTION_MOVE) {
            project.removeNodeFromParent(incomingNode);
        } else if (action == DnDConstants.ACTION_COPY) {
            incomingNode = incomingNode.copy();
        }
        
        project.insertNodeInto(incomingNode, targetNode, 0);
        expandPath(path);
        selectionModel.setSelectionPath(path.pathByAddingChild(incomingNode));

        dtde.acceptDrop(action);
    } else {
        dtde.rejectDrop();
    }
    
    finishDnD();
}
 
開發者ID:m-lima,項目名稱:KATscans,代碼行數:24,代碼來源:DraggableTree.java

示例6: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public synchronized void drop(DropTargetDropEvent event) {
	event.acceptDrop(DnDConstants.ACTION_COPY);
	try {
		@SuppressWarnings("unchecked")
		List<File> droppedFiles = (List<File>) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
		
		int count = droppedFiles.size();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < droppedFiles.size(); i++) {
			sb.append(droppedFiles.get(i));
			
			if (i != count-1) {
				sb.append("|");
			}
		}
		
		target.setText(sb.toString());
		
	} catch (UnsupportedFlavorException | IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
開發者ID:Emd4600,項目名稱:SporeModder,代碼行數:25,代碼來源:AdvancedFileChooser.java

示例7: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public synchronized void drop(DropTargetDropEvent event) {
	event.acceptDrop(DnDConstants.ACTION_COPY);
	try {
		@SuppressWarnings("unchecked")
		List<File> droppedFiles = (List<File>) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
		
		int count = droppedFiles.size();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < droppedFiles.size(); i++) {
			sb.append(droppedFiles.get(i));
			
			if (i != count-1) {
				sb.append("|");
			}
		}
		
		target.setText(sb.toString());
		
	} catch (UnsupportedFlavorException | IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
開發者ID:Emd4600,項目名稱:SporeModder,代碼行數:24,代碼來源:DropTargetTextField.java

示例8: getString

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
/**
 * Gets the string.
 *
 * @param event
 *            the event
 * @return the string
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws UnsupportedFlavorException
 *             the unsupported flavor exception
 */
@SuppressWarnings("unchecked")
static String getString(DropTargetDropEvent event) throws IOException, UnsupportedFlavorException {
	String text = null;
	DataFlavor fileList = DataFlavor.javaFileListFlavor;

	if (event.isDataFlavorSupported(fileList)) {
		event.acceptDrop(DnDConstants.ACTION_COPY);
		List<File> list = (List<File>) event.getTransferable().getTransferData(fileList);
		text = list.get(0).getAbsolutePath();
	} else if (event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
		event.acceptDrop(DnDConstants.ACTION_COPY);
		text = (String) event.getTransferable().getTransferData(DataFlavor.stringFlavor);
		if (text.startsWith("file://"))
			text = text.substring(7);
		text = stripSuffix(stripSuffix(text, "\n"), "\r").replaceAll("%20", " ");
	} else {
		event.rejectDrop();
		return null;
	}

	event.dropComplete(text != null);
	return text;
}
 
開發者ID:thorstenwagner,項目名稱:ij-ridgedetection,代碼行數:35,代碼來源:GenericDialogPlus.java

示例9: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
    setDragState(null, 0, 0);

    TabDragInfo dragInfo = getDragInfo(dtde.getTransferable());
    if (dragInfo != null) {
        if (dragInfo.tab != null && Utils.contains(dropZone, dtde.getLocation()) && isSnapInAllowed(dragInfo.tab)) {
            dtde.acceptDrop(dtde.getDropAction());
        } else {
            dtde.rejectDrop();
        }
    } else {
        dtde.rejectDrop();
    }

    dtde.dropComplete(true);
}
 
開發者ID:DJVUpp,項目名稱:Desktop,代碼行數:18,代碼來源:JhromeTabbedPaneUI.java

示例10: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public synchronized void drop (DropTargetDropEvent evt) {
	try {
		evt.acceptDrop(DnDConstants.ACTION_COPY);

		// nothing we can do about it, casting to generic list will be unsafe
		@SuppressWarnings("unchecked")
		List<File> droppedFiles = (List<File>)evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
		if (droppedFiles.size() > 1) return;

		File file = droppedFiles.get(0);
		listener.sendFile(instance, file);

	} catch (IOException | UnsupportedFlavorException e) {
		Log.exception(e);
	}
}
 
開發者ID:kotcrab,項目名稱:arget,代碼行數:18,代碼來源:SessionPanel.java

示例11: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
/**
 * The drag operation has terminated with a drop on this
 * <code>DropTarget</code>. This method is responsible for undertaking the
 * transfer of the data associated with the gesture. The
 * <code>DropTargetDropEvent</code> provides a means to obtain a
 * <code>Transferable</code> object that represents the data object(s) to be
 * transfered.
 * <P>
 * <P>
 * 
 * @param dtde the <code>DropTargetDropEvent</code>
 */
public void drop(DropTargetDropEvent dtde) {
    if (Debug.debugging("beanbox"))
        Debug.output("Enter> drop");

    dtde.acceptDrop(DnDConstants.ACTION_MOVE);
    extractTransferData(dtde);
    extractDropLocation(dtde);

    if (transferData == null || dropLocation == null)
        return;

    Component parent = ((DropTarget) dtde.getSource()).getComponent();

    dtde.dropComplete(true);

    showPopUp(parent);
    if (Debug.debugging("beanbox"))
        Debug.output("Exit> drop");
}
 
開發者ID:d2fn,項目名稱:passage,代碼行數:32,代碼來源:BeanBoxDnDCatcher.java

示例12: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
	if (mDragWasAcceptable) {
		dtde.acceptDrop(dtde.getDropAction());
		if (mModel.getDragColumn() != null) {
			dropColumn(dtde);
		} else {
			Row[] rows = mModel.getDragRows();

			if (rows != null && rows.length > 0) {
				dropRow(dtde);
			}
		}
		dtde.dropComplete(true);
	} else if (mAlternateDragDestination != null) {
		UIUtilities.convertPoint(dtde.getLocation(), this, mAlternateDragDestination);
		mAlternateDragDestination.drop(dtde);
	}
}
 
開發者ID:Ayutac,項目名稱:toolkit,代碼行數:20,代碼來源:Outline.java

示例13: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
    //System.out.println("drop(DropTargetDragEvent)");
    if (dtde.getSource() != dropTarget) {
        dtde.rejectDrop();
        panel.setDropLocation(-1, null);
        return;
    }
    Point dropPoint = dtde.getLocation();
    int index = list.locationToIndex(dropPoint);
    boolean dropped = false;
    if (index == -1 || index == draggedIndex) {
        //System.out.println("dropped onto self");
        dtde.rejectDrop();
        panel.setDropLocation(-1, null);
        return;
    }
    dtde.acceptDrop(DnDConstants.ACTION_MOVE);
    //System.out.println("accepted: " + draggedIndex + "/" + index);
    panel.setDropLocation(-1, null);
    panel.moveStep(draggedIndex, index);
    dropped = true;
    dtde.dropComplete(dropped);
}
 
開發者ID:mbraeunlein,項目名稱:ExtendedHodoku,代碼行數:25,代碼來源:ListDragAndDrop.java

示例14: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent dtde) {
	for (DataFlavor dataFlover : dtde.getCurrentDataFlavors()) {
		if (dataFlover.isFlavorJavaFileListType()) {
			try {
				dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

				for (File file : (List<File>)dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)) {
					if (file.isFile() && file.canRead()) {
						browseText.setText(file.getCanonicalPath());
						break;
					}
				}

				dtde.getDropTargetContext().dropComplete(true);	
			} catch (UnsupportedFlavorException e1) {
				//
			} catch (IOException e2) {
				//
			}
		}
	}
}
 
開發者ID:3dcitydb,項目名稱:importer-exporter,代碼行數:25,代碼來源:ExportPanel.java

示例15: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public synchronized void drop(DropTargetDropEvent dropTargetDropEvent) {
    try {
        final Transferable transferable = dropTargetDropEvent.getTransferable();
        if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY);
            dropTargetDropEvent.getDropTargetContext().dropComplete(true);
        }
        else {
            dropTargetDropEvent.rejectDrop();
        }
    }
    catch (Exception ex) {
        Log.error(ex);
        dropTargetDropEvent.rejectDrop();
    }
}
 
開發者ID:visit,項目名稱:spark-svn-mirror,代碼行數:17,代碼來源:FileDragLabel.java


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