本文整理匯總了Java中java.awt.dnd.DropTargetDragEvent.rejectDrag方法的典型用法代碼示例。如果您正苦於以下問題:Java DropTargetDragEvent.rejectDrag方法的具體用法?Java DropTargetDragEvent.rejectDrag怎麽用?Java DropTargetDragEvent.rejectDrag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.dnd.DropTargetDragEvent
的用法示例。
在下文中一共展示了DropTargetDragEvent.rejectDrag方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
}
示例2: 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();
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: dragEnter
import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
/** User is starting to drag over us */
public void dragEnter(DropTargetDragEvent dtde) {
if (!checkConditions(dtde)) {
dtde.rejectDrag();
} else {
lastIndex = comp.locationToIndex(dtde.getLocation());
cellRenderer.draggingEnter(lastIndex, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation());
comp.repaint(comp.getCellBounds(lastIndex, lastIndex));
}
}
示例6: 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;
}
}
}
示例7: 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();
}
}
示例8: 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();
}
}
示例9: 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();
}
}
示例10: dragOver
import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
/**
*
* @param e
*/
public void dragOver(DropTargetDragEvent e)
{
if (canImport)
{
mouseDragged(createEvent(e));
mxGraphTransferHandler handler = getGraphTransferHandler(e);
if (handler != null)
{
mxGraph graph = graphComponent.getGraph();
double scale = graph.getView().getScale();
Point pt = SwingUtilities.convertPoint(graphComponent,
e.getLocation(), graphComponent.getGraphControl());
pt = graphComponent.snapScaledPoint(new mxPoint(pt)).getPoint();
handler.setLocation(new Point(pt));
int dx = 0;
int dy = 0;
// Centers the preview image
if (centerPreview && transferBounds != null)
{
dx -= Math.round(transferBounds.getWidth() * scale / 2);
dy -= Math.round(transferBounds.getHeight() * scale / 2);
}
// Sets the drop offset so that the location in the transfer
// handler reflects the actual mouse position
handler.setOffset(new Point((int) graph.snap(dx / scale),
(int) graph.snap(dy / scale)));
pt.translate(dx, dy);
// Shifts the preview so that overlapping parts do not
// affect the centering
if (transferBounds != null && dragImage != null)
{
dx = (int) Math
.round((dragImage.getIconWidth() - 2 - transferBounds
.getWidth() * scale) / 2);
dy = (int) Math
.round((dragImage.getIconHeight() - 2 - transferBounds
.getHeight() * scale) / 2);
pt.translate(-dx, -dy);
}
if (!handler.isLocalDrag() && previewBounds != null)
{
setPreviewBounds(new Rectangle(pt, previewBounds.getSize()));
}
}
}
else
{
e.rejectDrag();
}
}
示例11: 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();
}
}
示例12: dragOver
import java.awt.dnd.DropTargetDragEvent; //導入方法依賴的package包/類
/**
*
* @param e
*/
public void dragOver(DropTargetDragEvent e) {
if (canImport) {
mouseDragged(createEvent(e));
mxGraphTransferHandler handler = getGraphTransferHandler(e);
if (handler != null) {
mxGraph graph = graphComponent.getGraph();
double scale = graph.getView().getScale();
Point pt = SwingUtilities.convertPoint(graphComponent, e.getLocation(),
graphComponent.getGraphControl());
pt = graphComponent.snapScaledPoint(new mxPoint(pt)).getPoint();
handler.setLocation(new Point(pt));
int dx = 0;
int dy = 0;
// Centers the preview image
if (centerPreview && transferBounds != null) {
dx -= Math.round(transferBounds.getWidth() * scale / 2);
dy -= Math.round(transferBounds.getHeight() * scale / 2);
}
// Sets the drop offset so that the location in the transfer
// handler reflects the actual mouse position
handler.setOffset(new Point((int) graph.snap(dx / scale), (int) graph.snap(dy / scale)));
pt.translate(dx, dy);
// Shifts the preview so that overlapping parts do not
// affect the centering
if (transferBounds != null && dragImage != null) {
dx = (int) Math
.round((dragImage.getIconWidth() - 2 - transferBounds.getWidth() * scale) / 2);
dy = (int) Math
.round((dragImage.getIconHeight() - 2 - transferBounds.getHeight() * scale) / 2);
pt.translate(-dx, -dy);
}
if (!handler.isLocalDrag() && previewBounds != null) {
setPreviewBounds(new Rectangle(pt, previewBounds.getSize()));
}
}
} else {
e.rejectDrag();
}
}