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


Java DropTargetDragEvent.acceptDrag方法代碼示例

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


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

示例1: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public void dragEnter(DropTargetDragEvent dtde) {
    accept = null;
    value = null;
    for (DataFlavor dataFlavor : dtde.getCurrentDataFlavors()) {
        Object obj = null;
        try {
            obj = dtde.getTransferable().getTransferData(dataFlavor);
        } catch (Exception ex) {
            continue;
        }
        if (dataFlavor.isFlavorJavaFileListType()) {
            accept = dataFlavor;
            value = obj;
            break;
        }
        if ("text".equals(dataFlavor.getPrimaryType()) && "uri-list".equals(dataFlavor.getSubType()) && dataFlavor.getRepresentationClass() == String.class) {
            accept = dataFlavor;
            value = (String) obj;
            break;
        }
    }
    if (accept != null) {
        dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:LocallDownloadDnD.java

示例2: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public void dragEnter(DropTargetDragEvent dtde) {
	if (
		((dtde.getDropAction() & DnDConstants.ACTION_MOVE) != 0) &&
		(dtde.getTransferable().isDataFlavorSupported(JDDLTransferData.DATA_FLAVOR))
	) {
		dtde.acceptDrag(DnDConstants.ACTION_MOVE);
	} else {
		dtde.rejectDrag();
	}
}
 
開發者ID:mgropp,項目名稱:pdfjumbler,代碼行數:12,代碼來源:TrashDropTargetListener.java

示例3: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public void dragOver(DropTargetDragEvent dtde) {
	if ((dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor) || (uriFlavor != null && dtde
			.isDataFlavorSupported(uriFlavor)))
			&& canOpenFile())
		dtde.acceptDrag(DnDConstants.ACTION_REFERENCE);
	else
		dtde.rejectDrag();
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:10,代碼來源:FileDropTargetListener.java

示例4: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public void dragEnter(DropTargetDragEvent dtde) {
    Collection<? extends ExternalDropHandler> handlers = Lookup.getDefault().lookupAll(ExternalDropHandler.class);
    for (ExternalDropHandler handler : handlers) {
        if (handler.canDrop(dtde)) {
            dtde.acceptDrag(DnDConstants.ACTION_COPY);
            isDragging = false;
            return;
        }
    }

    orig.dragEnter(dtde);
    isDragging = true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:QuietEditorPane.java

示例5: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public void dragOver(DropTargetDragEvent dtde) {
    Collection<? extends ExternalDropHandler> handlers = Lookup.getDefault().lookupAll(ExternalDropHandler.class);
    for (ExternalDropHandler handler : handlers) {
        if (handler.canDrop(dtde)) {
            dtde.acceptDrag(DnDConstants.ACTION_COPY);
            isDragging = false;
            return;
        }
    }

    orig.dragOver(dtde);
    isDragging = true;

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:QuietEditorPane.java

示例6: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
public void dragEnter(DropTargetDragEvent e) {
    if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
        isButtonDrag = true; //in case use is dragging something from the customizer window
    } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {
        e.rejectDrag();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:DnDSupport.java

示例7: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
public void dragOver(DropTargetDragEvent e) {
    if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) {
        updateDropGesture( e );
        if( !validateDropPosition() ) {
            e.rejectDrag();
        } else {
            e.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE );
        }
    } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {
        e.rejectDrag();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:DnDSupport.java

示例8: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
/** User drag over us */
public void dragOver(DropTargetDragEvent dtde) {
    if (!checkConditions(dtde)) {
        dtde.rejectDrag();

        if (lastIndex >= 0) {
            cellRenderer.draggingExit();
            comp.repaint(comp.getCellBounds(lastIndex, lastIndex));
            lastIndex = -1;
        }
    } else {
        dtde.acceptDrag(DnDConstants.ACTION_MOVE);

        int index = comp.locationToIndex(dtde.getLocation());

        if (lastIndex == index) {
            cellRenderer.draggingOver(index, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
        } else {
            if (lastIndex < 0) {
                lastIndex = index;
            }

            cellRenderer.draggingExit();
            cellRenderer.draggingEnter(index, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
            comp.repaint(comp.getCellBounds(lastIndex, index));
            lastIndex = index;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:IndexedCustomizer.java

示例9: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public final void dragEnter(DropTargetDragEvent dtde) {
	Point pt = dtde.getLocation();
	int action = dtde.getDropAction();
	if (drawImage) {
		paintImage(pt);
	}
	if (controller.canPerformAction(tree, draggedNode, action, pt)) {
		dtde.acceptDrag(action);
	} else {
		dtde.rejectDrag();
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:14,代碼來源:JTreeUtil.java

示例10: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public final void dragOver(DropTargetDragEvent dtde) {
	Point pt = dtde.getLocation();
	int action = dtde.getDropAction();
	autoscroll(tree, pt);
	if (drawImage) {
		paintImage(pt);
	}
	if (controller.canPerformAction(tree, draggedNode, action, pt)) {
		dtde.acceptDrag(action);
	} else {
		dtde.rejectDrag();
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:15,代碼來源:JTreeUtil.java

示例11: dropActionChanged

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public final void dropActionChanged(DropTargetDragEvent dtde) {
	Point pt = dtde.getLocation();
	int action = dtde.getDropAction();
	if (drawImage) {
		paintImage(pt);
	}
	if (controller.canPerformAction(tree, draggedNode, action, pt)) {
		dtde.acceptDrag(action);
	} else {
		dtde.rejectDrag();
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:14,代碼來源:JTreeUtil.java

示例12: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
/**
 * 
 */
public void dragEnter(DropTargetDragEvent e) {
  JComponent component = getDropTarget(e);
  TransferHandler th = component.getTransferHandler();
  boolean isLocal =
      th instanceof mxGraphTransferHandler && ((mxGraphTransferHandler) th).isLocalDrag();

  if (isLocal) {
    canImport = true;
  } else {
    canImport =
        graphComponent.isImportEnabled() && th.canImport(component, e.getCurrentDataFlavors());
  }

  if (canImport) {
    transferBounds = null;
    setVisible(false);

    try {
      Transferable t = e.getTransferable();

      if (t.isDataFlavorSupported(mxGraphTransferable.dataFlavor)) {
        mxGraphTransferable gt =
            (mxGraphTransferable) t.getTransferData(mxGraphTransferable.dataFlavor);
        dragCells = gt.getCells();

        if (gt.getBounds() != null) {
          mxGraph graph = graphComponent.getGraph();
          double scale = graph.getView().getScale();
          transferBounds = gt.getBounds();
          int w = (int) Math.ceil((transferBounds.getWidth() + 1) * scale);
          int h = (int) Math.ceil((transferBounds.getHeight() + 1) * scale);
          setPreviewBounds(
              new Rectangle((int) transferBounds.getX(), (int) transferBounds.getY(), w, h));

          if (imagePreview) {
            // Does not render fixed cells for local preview
            // but ignores movable state for non-local previews
            if (isLocal) {
              if (!isLivePreview()) {
                updateDragImage(graph.getMovableCells(dragCells));
              }
            } else {
              Object[] tmp = graphComponent.getImportableCells(dragCells);
              updateDragImage(tmp);

              // Shows no drag icon if import is allowed but none
              // of the cells can be imported
              if (tmp == null || tmp.length == 0) {
                canImport = false;
                e.rejectDrag();

                return;
              }
            }
          }

          setVisible(true);
        }
      }

      e.acceptDrag(TransferHandler.COPY_OR_MOVE);
    } catch (Exception ex) {
      // do nothing
      ex.printStackTrace();
    }

  } else {
    e.rejectDrag();
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:74,代碼來源:mxGraphHandler.java

示例13: dragEnter

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public void dragEnter(DropTargetDragEvent dtde) {
    dtde.acceptDrag(dtde.getDropAction());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:MissingEventsOnModalDialogTest.java

示例14: dragOver

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public void dragOver(DropTargetDragEvent dtde) {
    dtde.acceptDrag(dtde.getDropAction());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:MissingEventsOnModalDialogTest.java

示例15: dropActionChanged

import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
    dtde.acceptDrag(dtde.getDropAction());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:MissingEventsOnModalDialogTest.java


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