当前位置: 首页>>代码示例>>Java>>正文


Java DropTargetDropEvent.getLocation方法代码示例

本文整理汇总了Java中java.awt.dnd.DropTargetDropEvent.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java DropTargetDropEvent.getLocation方法的具体用法?Java DropTargetDropEvent.getLocation怎么用?Java DropTargetDropEvent.getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.dnd.DropTargetDropEvent的用法示例。


在下文中一共展示了DropTargetDropEvent.getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:19,代码来源:Map.java

示例2: 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();
	}
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:23,代码来源:JTableRenderer.java

示例3: 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();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:JTableRenderer.java

示例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, null);
		graph.setSelectionCell(edge);

		// System.out.println("clearing drag source");
		dragSource = null;
		e.dropComplete(true);
	}
	else
	{
		e.rejectDrop();
	}
}
 
开发者ID:md-k-sarker,项目名称:OWLAx,代码行数:23,代码来源:JTableRenderer.java

示例5: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(@Nonnull final DropTargetDropEvent dtde) {
  if (this.dragAcceptableType) {

    final Point dragPoint = dtde.getLocation();

    final TreePath path = getPathForLocation(dragPoint.x, dragPoint.y);

    if (path != null) {
      final Object dropTargetNode = path.getLastPathComponent();
      if (dropTargetNode instanceof NodeFileOrFolder) {
        final NodeFileOrFolder node = (NodeFileOrFolder) dropTargetNode;
        if (!node.isLeaf()) {
         //TODO processing of file drag in tree
         System.out.println("Not implemented yet!"); //NOI18N
        } else {
          dtde.rejectDrop();
        }
      }
    }

    repaint();
  }
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:25,代码来源:DnDTree.java

示例6: 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);
}
 
开发者ID:mbraeunlein,项目名称:ExtendedHodoku,代码行数:25,代码来源:ListDragAndDrop.java

示例7: WidgetDropTargetDropEvent

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
 * Creates a drop target drop event.
 * @param id the event id
 * @param event the Swing event
 */
public WidgetDropTargetDropEvent (long id, DropTargetDropEvent event) {
    this.id = id;
    this.event = event;
    Point location = event.getLocation ();
    x = location.x;
    y = location.y;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:WidgetAction.java

示例8: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent event) {
  removeDragCursor();
  Point pos = event.getLocation();
  pos.translate(currentPieceOffsetX, currentPieceOffsetY);
  myStack.pos.x = pos.x;
  myStack.pos.y = pos.y;
  myStack.stackConfigurer.updateDisplay();
  repaint();
  return;

}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:12,代码来源:SetupStack.java

示例9: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent event) {
  removeDragCursor();
  final Point dragEnd = event.getLocation();
  int x = dragEnd.x - dragStart.x;
  int y = dragEnd.y - dragStart.y;

  for (Region r : config.selectedRegions) {
    r.move(x, y, this);
    config.setDirty(true);
  }
  repaint();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:13,代码来源:RegionGrid.java

示例10: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public final void drop(DropTargetDropEvent dtde) {
	try {
		if (drawImage) {
			clearImage();
		}
		int action = dtde.getDropAction();
		Transferable transferable = dtde.getTransferable();
		Point pt = dtde.getLocation();
		if (transferable.isDataFlavorSupported(NODE_FLAVOR)
				&& controller.canPerformAction(tree, draggedNode, action, pt)) {
			TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
			Object node = transferable.getTransferData(NODE_FLAVOR);
			Object newParentNode = pathTarget.getLastPathComponent();
			if (controller.executeDrop(tree, node, newParentNode, action)) {
				dtde.acceptDrop(action);
				dtde.dropComplete(true);
				return;
			}
		}
		dtde.rejectDrop();
		dtde.dropComplete(false);
	} catch (Exception e) {
		dtde.rejectDrop();
		dtde.dropComplete(false);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:28,代码来源:JTreeUtil.java

示例11: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
	if(draggingComponent==null) {
		dtde.rejectDrop();
	} else {

		if(draggingDefaults) {
			setContents(getDefaultContents());
		} else {
			Point p = dtde.getLocation();
			p = SwingUtilities.convertPoint(
					((DropTarget)dtde.getSource()).getComponent(), 
					p, 
					CustomizedToolbar.this );
			
			String[] contents = getContents(p);
			setContents(contents);
			dtde.acceptDrop(DnDConstants.ACTION_MOVE);
			JComponent theComponent = getComponent(draggingComponent);
			Rectangle r = (Rectangle)theComponent.getClientProperty(AnimatedLayout.DESTINATION);
			if(r!=null) {
				theComponent.setBounds( r );
			}
			if(hideActiveComponents)
				theComponent.setVisible(true);
		}
	}
	dtde.dropComplete(true);
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:29,代码来源:CustomizedToolbar.java

示例12: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
    Point p = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    // Sets the original glass pane
    setOriginalGlassPane(tree);
    // Cancel tree item expanding
    dragOverTreePath = null;
    // Get the parent and sibling paths and nodes
    TreePath currentPath = tree.getPathForLocation(p.x, p.y);
    DefaultMutableTreeNode parent =
        (DefaultMutableTreeNode) getNodeForPath
            (getParentPathForPosition(currentPath));
    Node dropTargetNode = getDomNodeFromTreeNode(parent);
    DefaultMutableTreeNode sibling =
        (DefaultMutableTreeNode)
            getNodeForPath(getSiblingPathForPosition(currentPath));
    Node siblingNode = getDomNodeFromTreeNode(sibling);
    if (this.transferData != null) {
        ArrayList nodelist =
            getNodeListForParent(this.transferData.getNodeList(),
                                 dropTargetNode);
        fireDropCompleted
            (new DOMDocumentTreeEvent
                (new DropCompletedInfo
                    (dropTargetNode, siblingNode, nodelist)));
        dtde.dropComplete(true);
        return;
    }
    dtde.rejectDrop();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:32,代码来源:DOMDocumentTree.java

示例13: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public synchronized void drop(DropTargetDropEvent dtde) {
	try {
		TreeNode sourceNode = (TreeNode) dtde.getTransferable().getTransferData(
				NodeTransferWrapper.ATLAS_OBJECT_FLAVOR);

		Point pt = dtde.getLocation();
		DropTargetContext dtc = dtde.getDropTargetContext();
		JTree tree = (JTree) dtc.getComponent();
		TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
		TreeNode targetNode = (TreeNode) parentpath.getLastPathComponent();

		if (targetNode.equals(sourceNode) || targetNode.getParent().equals(sourceNode)) {
			dtde.rejectDrop();
			return;
		}
		AtlasTreeModel atlasTreeModel = (AtlasTreeModel) atlasTree.getModel();
		if (sourceNode instanceof LayerInterface && targetNode instanceof LayerInterface)
			mergeLayers(atlasTreeModel, (LayerInterface) sourceNode,
					(LayerInterface) targetNode);

		if (targetNode instanceof MapInterface)
			// We can not make a map child of another map
			// -> use it's layer instead
			targetNode = targetNode.getParent();

		if (sourceNode instanceof MapInterface && targetNode instanceof LayerInterface)
			moveMap(atlasTreeModel, (MapInterface) sourceNode, (LayerInterface) targetNode);

	} catch (Exception e) {
		log.error("", e);
		atlasTree.getTreeModel().notifyStructureChanged();
		dtde.rejectDrop();
	}
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:35,代码来源:DragDropController.java

示例14: dropObjectFromModelBrowser

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
 * 
 * Accepts a drag of a class from the ModelBrowser. A new object of this
 * class will be created.
 * @param dtde
 */
public void dropObjectFromModelBrowser( DropTargetDropEvent dtde ) {

    try {
        dtde.acceptDrop(DnDConstants.ACTION_MOVE);
        Transferable transferable = dtde.getTransferable();

        // we accept only Strings
        if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            String s = (String) transferable
                    .getTransferData(DataFlavor.stringFlavor);

            if (s.startsWith("CLASS-")) {
                Point p = dtde.getLocation();
                if ( isDoAutoLayout() ) {
                    getRandomNextPosition();
                } else {                    
                    nextNodePosition.x = p.getX();
                    nextNodePosition.y = p.getY();
                }
                String clsName = s.substring(6);
                fParent.createObject(clsName);
            }
        }
        dtde.dropComplete(true);
    } catch (IOException exception) {
        exception.printStackTrace();
        System.err.println("Exception" + exception.getMessage());
        dtde.dropComplete(false);
    } catch (UnsupportedFlavorException ufException) {
        ufException.printStackTrace();
        System.err.println("Exception" + ufException.getMessage());
        dtde.dropComplete(false);
    }
}
 
开发者ID:vnu-dse,项目名称:rtl,代码行数:41,代码来源:NewObjectDiagram.java

示例15: extractDropLocation

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
private void extractDropLocation(DropTargetDropEvent dtde) {
    if (dtde == null) {
        System.out.println("ERROR> BDnDC::getTransferData(): dropEvent is null");
        return;
    }

    dropLocation = dtde.getLocation();
}
 
开发者ID:d2fn,项目名称:passage,代码行数:9,代码来源:BeanBoxDnDCatcher.java


注:本文中的java.awt.dnd.DropTargetDropEvent.getLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。