本文整理匯總了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;
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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");
}
示例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);
}
}
示例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);
}
示例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) {
//
}
}
}
}
示例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();
}
}