當前位置: 首頁>>代碼示例>>Java>>正文


Java DragGestureEvent類代碼示例

本文整理匯總了Java中java.awt.dnd.DragGestureEvent的典型用法代碼示例。如果您正苦於以下問題:Java DragGestureEvent類的具體用法?Java DragGestureEvent怎麽用?Java DragGestureEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DragGestureEvent類屬於java.awt.dnd包,在下文中一共展示了DragGestureEvent類的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: start

import java.awt.dnd.DragGestureEvent; //導入依賴的package包/類
public void start(final DragGestureEvent e) {
    originalLocationOnScreen = source.getComponent().getLocationOnScreen();
    final Rectangle tabRect = source.getTabBounds(tabIndex);
    if( prefs.getBoolean(WinSysPrefs.DND_SMALLWINDOWS, true) ) {
        originalLocationOnScreen.x += tabRect.x;
    }

    DragWindow tmp = createDragWindow( tabIndex );
    if( null != tmp ) {
        dragOffset = new Point( 0, 0 );
        Point loc = new Point( e.getDragOrigin() );
        SwingUtilities.convertPointToScreen(loc, e.getComponent());
        tmp.setLocation( loc.x-dragOffset.x, loc.y-dragOffset.y );
        //let the JNA transparency stuff to kick in
        try {
            tmp.setVisible( true );
            //make drag window visible, i.e. move to proper location,
            //dragImage.setLocation( startingPoint );
            dragWindow = tmp;
        } catch( UnsatisfiedLinkError ulE ) {
            Logger.getLogger(DragAndDropFeedbackVisualizer.class.getName()).log(Level.INFO, null, ulE);
        } catch( Throwable ex ) {
            Logger.getLogger(DragAndDropFeedbackVisualizer.class.getName()).log(Level.FINE, null, ex);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:DragAndDropFeedbackVisualizer.java

示例3: 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

示例4: 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

示例5: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //導入依賴的package包/類
public void dragGestureRecognized(DragGestureEvent dge) {
	Point p = dge.getDragOrigin();
	Component c = dge.getComponent();
	JFrame f = (JFrame)SwingUtilities.getWindowAncestor(c);
	p = SwingUtilities.convertPoint(c, p, f);
	
	for(int a = 0; a<componentList.length; a++) {
		if(triggerDrag(f,p,dge,componentList[a]))
			return;
	}
	//double-check for separators & gaps:
	for(int a = 0; a<getComponentCount(); a++) {
		if(triggerDrag(f,p,dge,(JComponent)getComponent(a)))
			return;
	}
	
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:18,代碼來源:CustomizedToolbar.java

示例6: 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

示例7: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //導入依賴的package包/類
public void dragGestureRecognized(DragGestureEvent dge) {
	
	Point p = dge.getDragOrigin();
	MockComponent mc = (MockComponent)dge.getComponent();
	Transferable transferable = new MockComponentTransferable(mc);
	BufferedImage bi = mc.getBufferedImage();
	if(mc instanceof MockDefaultToolbar) {
		toolbar.draggingComponent = "";
	} else if(mc.getName().equals("-")) {
		toolbar.draggingComponent = toolbar.getNewSeparatorName();
	} else if(mc.getName().equals(" ")) {
		toolbar.draggingComponent = toolbar.getNewSpaceName();
	} else if(mc.getName().equals("\t")) {
		toolbar.draggingComponent = toolbar.getNewFlexibleSpaceName();
	} else {
		toolbar.draggingComponent = mc.getName();
	}
	toolbar.draggingDefaults = (mc instanceof MockDefaultToolbar);
	toolbar.draggingFromToolbar = false;
	dge.startDrag(DragSource.DefaultMoveDrop, 
			bi, 
			new Point(-p.x, -p.y), 
			transferable, 
			dragSourceListener);
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:26,代碼來源:CustomizedToolbarOptions.java

示例8: 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:vilie,項目名稱:javify,代碼行數:22,代碼來源:TransferHandler.java

示例9: 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

示例10: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //導入依賴的package包/類
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
	if (dge.getDragAction() == DnDConstants.ACTION_COPY) {
		Point p = dge.getDragOrigin();
		
		for (int i = 0; i < constraints.size(); i++) {
			Component cmp = operationPanel.getComponent(i);
			if (cmp.getBounds().contains(p)) {
				rootFrame.glassPane.setImage(PivotSlice.getScreenShot(cmp));
				dge.startDrag(DragSource.DefaultCopyDrop, new Constraint.TransferableConstraint(constraints.get(i)));
				
				rootFrame.logger.logAction("historypanel-drag attribute");
				break;
			}
		}
	}
}
 
開發者ID:jeffjianzhao,項目名稱:PivotSlice,代碼行數:18,代碼來源:HistoryPanel.java

示例11: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //導入依賴的package包/類
@Override
public void dragGestureRecognized(DragGestureEvent e) {
	dragRecogonized = true;
	if (e.getDragAction() == DnDConstants.ACTION_COPY) {
		if (timer.isRunning())
			timer.stop();
		
		String text = searchBox.getText().toLowerCase();
		if (text.startsWith("/")) {
			for (int i = 0; i < facetSearchTags.length; i++) {
				if (text.startsWith(facetSearchTags[i])) {
					Constraint.ConstraintData cdata = generateConstraintData(i, text);
					if (cdata == null)
						return;
					
					rootFrame.glassPane.setImage(PivotSlice.getScreenShot(searchBox));
					e.startDrag(DragSource.DefaultCopyDrop, new Constraint.TransferableConstraint(cdata));
					
					rootFrame.logger.logAction("searchpanel-drag attribute");
					break;
				}
			}
		}
	}
}
 
開發者ID:jeffjianzhao,項目名稱:PivotSlice,代碼行數:26,代碼來源:SearchPanel.java

示例12: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //導入依賴的package包/類
@Override
public void dragGestureRecognized(DragGestureEvent dge) {

	Component component = dge.getComponent();

	@SuppressWarnings("unchecked")
	JList<IToolTipItem> fileList = (JList<IToolTipItem>) component;

	IToolTipItem item = fileList.getSelectedValue();
	int index = fileList.getSelectedIndex();

	if (item != null) {
		dge.startDrag(null, new TransferableJListToolTipItem(item, index));
		log.debug("Dragging \"" + item.getValue() + "\"");
	}
}
 
開發者ID:aguelle,項目名稱:MIDI-Automator,代碼行數:17,代碼來源:ItemListDragGestureListener.java

示例13: 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

示例14: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //導入依賴的package包/類
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
    if (!tabbedPane.isEnabled()) {
        return;
    }

    dragOrigin = dge.getDragOrigin();

    Tab draggedTab = getDraggableTabAt(dragOrigin);
    if (draggedTab != null) {
        Window window = SwingUtilities.getWindowAncestor(tabbedPane);
        Dimension sourceWindowSize = null;
        if (window != null) {
            sourceWindowSize = window.getSize();
        }
        Point p = SwingUtilities.convertPoint(tabbedPane, dragOrigin, draggedTab);
        double grabX = p.x / (double) draggedTab.getWidth();

        dragInfo = new TabDragInfo(draggedTab, dragOrigin, grabX, floatingTabHandler, sourceWindowSize);
        source.startDrag(dge, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR), transferableStore.createTransferable(dragInfo), this);
    }
}
 
開發者ID:DJVUpp,項目名稱:Desktop,代碼行數:23,代碼來源:JhromeTabbedPaneUI.java

示例15: dragGestureRecognized

import java.awt.dnd.DragGestureEvent; //導入依賴的package包/類
@Override
public void dragGestureRecognized(DragGestureEvent dge)
{
	if (this.canDrag)
	{
		this.oldParent = (CardCollection)this.card.getParent();
		this.location = this.oldParent.getCardLocation(this.card);
		this.card.cardLocation = this.location;
		this.oldParent.setCard(new CardWindow(), this.location);
		this.oldParent.validate();
		this.oldParent.repaint();
		
		DragSource source = dge.getDragSource();
		source.startDrag(dge, Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR), this.card, this);
	}
}
 
開發者ID:slaymaker1907,項目名稱:triple-triad-ai,代碼行數:17,代碼來源:CardDragHandler.java


注:本文中的java.awt.dnd.DragGestureEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。