本文整理汇总了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);
}
}
示例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();
}
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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;
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例13: dragEnter
import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
@Override
public void dragEnter(DropTargetDragEvent dtde) {
dtde.acceptDrag(dtde.getDropAction());
}
示例14: dragOver
import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
@Override
public void dragOver(DropTargetDragEvent dtde) {
dtde.acceptDrag(dtde.getDropAction());
}
示例15: dropActionChanged
import java.awt.dnd.DropTargetDragEvent; //导入方法依赖的package包/类
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
dtde.acceptDrag(dtde.getDropAction());
}