当前位置: 首页>>代码示例>>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;未经允许,请勿转载。