當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。