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