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


Java DragGestureEvent.startDrag方法代码示例

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


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

示例1: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void dragGestureRecognized(DragGestureEvent dge) {
    JComponent c = (JComponent)dge.getComponent();
    DefaultTransferHandler th
        = (DefaultTransferHandler)c.getTransferHandler();
    Transferable t = th.createTransferable(c);
    if (t == null) {
        logger.warning("Unable to create transferable for: " + dge);
        th.exportDone(c, null, NONE);
        return;
    }

    this.scrolls = c.getAutoscrolls();
    c.setAutoscrolls(false);
    try {
        Cursor cursor = getCursor(c);
        dge.startDrag(cursor, t, this);
    } catch (RuntimeException re) {
        c.setAutoscrolls(this.scrolls);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:DefaultTransferHandler.java

示例2: beginDragging

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
protected void beginDragging(DragGestureEvent dge) {
  // this call is needed to instantiate the boundingBox object
 final BufferedImage bImage = makeDragImage(dragPieceOffCenterZoom);

  final Point dragPointOffset = new Point(
    getOffsetMult() * (boundingBox.x + currentPieceOffsetX - EXTRA_BORDER),
    getOffsetMult() * (boundingBox.y + currentPieceOffsetY - EXTRA_BORDER)
  );

  dge.startDrag(
    Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
    bImage,
    dragPointOffset,
    new StringSelection(""),
    this
  );

  dge.getDragSource().addDragSourceMotionListener(this);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:PieceMover.java

示例3: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
    String [] filesAsStringArray = list.getItems();
    File [] files = new File[filesAsStringArray.length];
    for (int fileNumber=0; fileNumber<filesAsStringArray.length ; fileNumber++ ) {
        files[fileNumber]=new File(filesAsStringArray[fileNumber]);
    }
    dge.startDrag(null, new FileListTransferable(Arrays.asList(files)));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:SourceFileListFrame.java

示例4: triggerDrag

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
private boolean triggerDrag(JFrame f,Point p,DragGestureEvent dge,JComponent c) {
	Rectangle r = new Rectangle(0,0,c.getWidth(),c.getHeight());
	r = SwingUtilities.convertRectangle(c, 
			r, 
			f);
	
	if(r.contains(p)) {
		draggingFromToolbar = true;
			draggingDefaults = false;
		draggingComponent = c.getName();
		MockComponent mc = new MockComponent(c);
		Transferable transferable = new MockComponentTransferable(mc);
		BufferedImage bi = mc.getBufferedImage();
		dge.startDrag(DragSource.DefaultMoveDrop, 
				bi, 
				new Point(r.x-p.x, r.y-p.y), 
				transferable, 
				dragSourceListener);
		return true;
	}
	return false;
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:23,代码来源:CustomizedToolbar.java

示例5: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
/**
 * Drag gesture recognized. Start the drag off if valid.
 *
 * @param evt
 *            Drag gesture event
 */
@Override
public void dragGestureRecognized(DragGestureEvent evt) {
	DragEntry dragEntry = kseFrame.dragSelectedEntry();

	if (dragEntry == null) {
		return;
	}

	ImageIcon icon = dragEntry.getImage();

	// Draw image as drag cursor
	Toolkit toolkit = Toolkit.getDefaultToolkit();
	Dimension dim = toolkit.getBestCursorSize(icon.getIconWidth(), icon.getIconHeight());
	BufferedImage buffImage = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB_PRE);
	icon.paintIcon(evt.getComponent(), buffImage.getGraphics(), 0, 0);
	cursor = toolkit.createCustomCursor(buffImage, new Point(0, 0), "keystore-entry");

	evt.startDrag(cursor, new KeyStoreEntryTransferable(dragEntry), this);
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:26,代码来源:KeyStoreEntryDragGestureListener.java

示例6: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
	if (model == null || !isDraggingEnabled) {
		return;
	}
	int index = getImageIndexAt(dge.getDragOrigin().x, dge.getDragOrigin().y);
	if (index < 0) {
		return;
	}
	Transferable transferable = model.getTransferable(index);
	if (transferable == null) {
		return;
	}
	//dge.startDrag(Toolkit.getDefaultToolkit().createCustomCursor(model.getImage(index), new Point(0, 0), "Thumbnail"), transferable, this);
	dge.startDrag(getDragCursor(), transferable, this);
	DragSource.getDefaultDragSource().addDragSourceMotionListener(this);
}
 
开发者ID:RPTools,项目名称:rplib,代码行数:17,代码来源:ImagePanel.java

示例7: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent e)
{
  JComponent c = (JComponent) e.getComponent();
  TransferHandler th = c.getTransferHandler();
  Transferable t = th.createTransferable(c);
  if (t != null)
    {
      autoscrolls = c.getAutoscrolls();
      c.setAutoscrolls(false);
      try
        {
          e.startDrag(null, t, this);
          return;
        }
      finally
        {
          c.setAutoscrolls(autoscrolls);
        }
    }
  th.exportDone(c, t, NONE);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:22,代码来源:TransferHandler.java

示例8: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent event) {
	// ignore right-click-drags
	if (((MouseEvent) event.getTriggerEvent()).isPopupTrigger())
		return;

	// figure out what's being dragged
	Point p = event.getDragOrigin();
	BaseSample bar = bgp.getBar(p);

	// this only makes sense with Files...
	if(bar.getLoader() instanceof FileElement) {
		// make a Transferable to send
		Transferable transfer = new Tree.TransferableFile(
				((FileElement)bar.getLoader()).getFilename());

		// let the drag begin!
		event.startDrag(DragSource.DefaultCopyDrop, transfer, this);
	}
}
 
开发者ID:ltrr-arizona-edu,项目名称:tellervo,代码行数:20,代码来源:BargraphFrame.java

示例9: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized( DragGestureEvent dge ) {
    Transferable t = null;
    
    if( dge.getComponent() instanceof CategoryButton ) {
        //trying to drag a palette category
        CategoryButton button = (CategoryButton)dge.getComponent();
        draggingCategory = button.getCategory();
        t = draggingCategory.getTransferable();
        
    } else if( dge.getComponent() instanceof CategoryList ) {
        //trying to drag a palette item
        CategoryList list = (CategoryList)dge.getComponent();
        int selIndex = list.locationToIndex( dge.getDragOrigin() );
        draggingItem = list.getItemAt( selIndex );
        if( null == draggingItem ) {
            return;
        }
        t = draggingItem.drag();
        dragSourceCategoryList = list;
    }
    if( null != t ) {
        dge.getDragSource().addDragSourceListener( getDragSourceListener() );
        try {
            dge.startDrag( null, t );
        } catch( InvalidDnDOperationException idndE ) {
            //attempt to fix #110670
            try {
                dge.startDrag( null, t );
            } catch( InvalidDnDOperationException e ) {
                ERR.log( Level.INFO, idndE.getMessage(), e );
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:DnDSupport.java

示例10: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {

      Point mousePosition = dge.getDragOrigin();
      Point piecePosition = new Point(myStack.pos);

      // Check drag starts inside piece
      Rectangle r = myStack.stackConfigurer.getPieceBoundingBox();
      r.translate(piecePosition.x, piecePosition.y);
      if (!r.contains(mousePosition)) {
        return;
      }

      originalPieceOffsetX = piecePosition.x - mousePosition.x;
      originalPieceOffsetY = piecePosition.y - mousePosition.y;

      drawWin = null;

      makeDragCursor();
      setDragCursor();

      SwingUtilities.convertPointToScreen(mousePosition, drawWin);
      moveDragCursor(mousePosition.x, mousePosition.y);

      // begin dragging
      try {
        dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
                      new StringSelection(""), this); // DEBUG
        dge.getDragSource().addDragSourceMotionListener(this);
      }
      catch (InvalidDnDOperationException e) {
        ErrorDialog.bug(e);
      }
    }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:34,代码来源:SetupStack.java

示例11: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {

        final Point mousePosition = dge.getDragOrigin();
        dragStart = new Point(mousePosition);
        final Region r = grid.getRegion(mousePosition);
        if (r == null) {
          return;
        }

        Point piecePosition = new Point(r.getOrigin());

        originalPieceOffsetX = piecePosition.x - mousePosition.x;
        originalPieceOffsetY = piecePosition.y - mousePosition.y;

        drawWin = null;

        makeDragCursor();
        setDragCursor();

        SwingUtilities.convertPointToScreen(drawOffset, drawWin);
        SwingUtilities.convertPointToScreen(mousePosition, drawWin);
        moveDragCursor(mousePosition.x, mousePosition.y);

        // begin dragging
        try {
          dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
                        new StringSelection(""), this); //$NON-NLS-1$
          dge.getDragSource().addDragSourceMotionListener(this);
        }
        catch (InvalidDnDOperationException e) {
          ErrorDialog.bug(e);
        }
      }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:34,代码来源:RegionGrid.java

示例12: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
	Cursor cursor = null;
	if(dge.getComponent() instanceof RepositoryViewer){
		RepositoryViewer rv = (RepositoryViewer) dge.getComponent();
		KernelRepositoryEntry kre = (KernelRepositoryEntry) rv.getSelectedValue();
		
		if(dge.getDragAction()==DnDConstants.ACTION_COPY){
			cursor = DragSource.DefaultCopyDrop;
		}
		
		dge.startDrag(cursor, new TransferableKernelRepositoryEntry(kre));
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:15,代码来源:RepositoryViewerDragGestureListener.java

示例13: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
    java.util.List<URI> uriList = Stream.of(list.getItems())
                                            .map(File::new)
                                            .map(File::toURI)
                                            .collect(Collectors.toList());

    dge.startDrag(null, new URIListTransferable(uriList));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:SourceFileListFrame.java

示例14: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent e)
{
  try
    {
      Transferable t = new StringSelection(getText());
      e.startDrag(DragSource.DefaultCopyNoDrop, t, this);
    }
  catch (InvalidDnDOperationException e2)
    {
      System.out.println(e2);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:13,代码来源:Demo.java

示例15: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //导入方法依赖的package包/类
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
	rootFrame.glassPane.setImage(PivotSlice.getScreenShot(this));
	if (dge.getDragAction() == DnDConstants.ACTION_COPY) {
		dge.startDrag(DragSource.DefaultCopyDrop, new TransferableConstraint(constrData));
	}
	else {
		dge.startDrag(DragSource.DefaultMoveDrop, new TransferableConstraint(constrData));
		setConstraintData(new ConstraintData(constrData.facetID));
		childUpdated();
	}
	
	rootFrame.logger.logAction("filter-drag constraint");
}
 
开发者ID:jeffjianzhao,项目名称:PivotSlice,代码行数:15,代码来源:Constraint.java


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