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


Java DropTargetDropEvent.dropComplete方法代碼示例

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


在下文中一共展示了DropTargetDropEvent.dropComplete方法的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包/類
public void drop(DropTargetDropEvent dtde) {
    boolean res = false;
    try {
        if( isButtonDrag ) {
            if( validateDropPosition() ) {
                res = handleDrop( dtde.getTransferable() );
            }
        } else if( isToolbarDrag ) {
            res = true;
            //taken care of in dragDropEnd()
        }
    } finally {
        dtde.dropComplete(res);
    }
    resetDropGesture();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:DnDSupport.java

示例3: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde) {
  if (dtde.getDropTargetContext().getComponent() == theMap) {
    final MouseEvent evt = new MouseEvent(
      theMap,
      MouseEvent.MOUSE_RELEASED,
      System.currentTimeMillis(),
      0,
      dtde.getLocation().x,
      dtde.getLocation().y,
      1,
      false
    );
    theMap.dispatchEvent(evt);
    dtde.dropComplete(true);
  }

  if (scroller.isRunning()) scroller.stop();
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:19,代碼來源:Map.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,代碼行數:23,代碼來源:JTableRenderer.java

示例5: 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

示例6: 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, null);
		graph.setSelectionCell(edge);

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

示例7: 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

示例8: 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

示例9: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde) {
	if ((dtde.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0) {
		// Accept the drop and get the transfer data
		dtde.acceptDrop(dtde.getDropAction());
		Transferable transferable = dtde.getTransferable();
		boolean dropSucceeded = false;

		try {
			window
					.setCursor(Cursor
							.getPredefinedCursor(Cursor.WAIT_CURSOR));

			dropSucceeded = dropFile(dtde.getDropAction(), transferable,
					dtde.getLocation());

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			window.setCursor(Cursor.getDefaultCursor());
			dtde.dropComplete(dropSucceeded);
		}
	} else {
		dtde.dropComplete(false);
	}
}
 
開發者ID:yjgoo,項目名稱:pdm-viewer,代碼行數:26,代碼來源:DropFileLoader.java

示例10: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(final DropTargetDropEvent e) {
    int length = end - start;
    int insertPosition = textComponent.viewToModel(e.getLocation());
    try {
        textComponent.getDocument().remove(start, length);
        if (insertPosition > end) {
            insertPosition -= length;
        } else {
            if (insertPosition >= start) {
                insertPosition = start;
            }
        }
        textComponent.getDocument().insertString(insertPosition, str,
                                                 null);
        textComponent.replaceSelection("");
        textComponent.setCaretPosition(insertPosition + length);

    } catch (final BadLocationException ex) {
    }
    e.dropComplete(true);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:BasicTextUI.java

示例11: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
    try {
        final Transferable transferable = dtde.getTransferable();
        if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            final List<File> fileList = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
            if (fileList.size() > 0) {
                final OpenProductAction open = new OpenProductAction();
                open.setFiles(fileList.toArray(new File[fileList.size()]));
                dtde.dropComplete(Boolean.TRUE.equals(open.execute()));
            }
        } else {
            dtde.rejectDrop();
        }
    } catch (UnsupportedFlavorException | IOException ignored) {
        dtde.rejectDrop();
    }
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:20,代碼來源:ProductExplorerTopComponent.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包/類
public void drop(DropTargetDropEvent dtde) {
    gestureStarted = false;
    if ((dtde.getDropAction() & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE) {
        dtde.acceptDrop(DnDConstants.ACTION_MOVE);
        Transferable t = dtde.getTransferable();

        try {
            DBTableInternalFrame iFrame = (DBTableInternalFrame) t
                    .getTransferData(InternalFrameTransferable.DATA_FLAVOR);
            if (iFrame != DBTableInternalFrame.this) {
                JoinLine joinLine = new JoinLine(iFrame, iFrame
                        .getSelectedRow(), DBTableInternalFrame.this,
                        columnsListBox.getSelectedIndex());
                desktop.addJoinLine(joinLine);
                desktop.repaint();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        dtde.dropComplete(true);
    }
}
 
開發者ID:nextreports,項目名稱:nextreports-designer,代碼行數:24,代碼來源:DBTableInternalFrame.java

示例15: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent event) {
    int dropAction = event.getDropAction();
    JComponent c = (JComponent) event.getDropTargetContext().getComponent();
    DataObjectTransferHandler transferHandler = (DataObjectTransferHandler) c.getTransferHandler();

    if (canImport && (transferHandler != null) && actionSupported(dropAction)) {
        event.acceptDrop(dropAction);
        try {
            Transferable transferable = event.getTransferable();
            transferHandler.setDropPoint(event.getLocation());
            transferHandler.setDropComponent(c);
            event.dropComplete(transferHandler.importData(c, transferable));
        } catch (RuntimeException e) {
            event.dropComplete(false);
        }
    } else {
        event.rejectDrop();
    }
}
 
開發者ID:nextreports,項目名稱:nextreports-designer,代碼行數:20,代碼來源:DataObjectTransferHandler.java


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