Java 8 DragGestureEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DragGestureEvent class.

This code example shows how to use the following methods:getComponent, getDragAction, getDragOrigin, getTriggerEvent, startDrag
/** 
 * The NodeDragListener which belongs to every NodeView 
 */ 
public class MNodeDragListener implements DragGestureListener {
	public void dragGestureRecognized(final DragGestureEvent e) {
		final MainView mainView = (MainView) e.getComponent();
		final NodeView nodeView = mainView.getNodeView();
		if(! nodeView.isSelected()){
			nodeView.getMap().getModeController().getController().getSelection().selectAsTheOnlyOneSelected(nodeView.getModel());
		} 
		Rectangle bounds = new Rectangle(0, 0, mainView.getWidth(), mainView.getHeight());
		if(!bounds.contains(e.getDragOrigin()))
			return; 
		final int dragActionType = e.getDragAction();
		if (dragActionType == DnDConstants.ACTION_MOVE) {
			final NodeModel node = nodeView.getModel();
			if (node.isRoot()) {
				if(! isLinkDragEvent(e))
					return; 
			} 

6
CodeRank
This code example shows how to use the following methods:getComponent, startDrag
     
    /** 
     * Initiates a drag with the files in the selected rows. 
     */ 
    public void dragGestureRecognized(DragGestureEvent dge) {
        JComponent c = (JComponent) dge.getComponent();
        LimeTransferHandler th = (LimeTransferHandler)c.getTransferHandler();
         
        //This is a LibraryTableTransferHandler.createTransferable(component) 
        Transferable t = th.createTransferable(c);
         
        if (t != null) {
            boolean scrolls = c.getAutoscrolls();
            c.setAutoscrolls(false);
            try { 
 
                Image img = null;
                if(DragSource.isDragImageSupported())
                    img = th.getImageRepresentation(t);
 

5
CodeRank
This code example shows how to use the following methods:getDragAction, getDragOrigin, startDrag
 
	 
	//	DragGestureListener method 
	public void dragGestureRecognized(DragGestureEvent event)
	{ 
		final Point location = event.getDragOrigin();
		final TreePath path = tree.getPathForLocation(location.x, location.y);
		if(path == null)
			{return;} 
 
		final int action = event.getDragAction();
		final XACMLTreeNode transferNode = (XACMLTreeNode)path.getLastPathComponent();
		final Cursor cursor = (action == DnDConstants.ACTION_MOVE) ? DragSource.DefaultMoveDrop : DragSource.DefaultCopyDrop;
		event.startDrag(cursor, new NodeTransferable(transferNode), this);
	} 
	// DropTargetListener methods 
	public void drop(DropTargetDropEvent event)
	{ 
		event.acceptDrop(event.getDropAction());
		 
4
CodeRank
This code example shows how to use the following methods:startDrag
        setBackground(Color.RED);
    } 
 
    private class MyDragGestureListener implements DragGestureListener {
        public void dragGestureRecognized(DragGestureEvent dge) {
            dge.startDrag(null, new FileListTransferable());
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:getTriggerEvent
     * <P> 
     * @param e the <code>DragGestureEvent</code> describing 
     * the gesture that has just occurred 
     */ 
	public void dragGestureRecognized(DragGestureEvent e) {
	    InputEvent in = e.getTriggerEvent();
	    if (in instanceof MouseEvent) {
			MouseEvent evt = (MouseEvent)in;
			boolean isLeftMouse = SwingUtilities.isLeftMouseButton(evt);
 
		    if (isLeftMouse && !evt.isAltDown()) {
		    	this.requestFocus();
				dragSource.startDrag(e, DragSource.DefaultCopyDrop, this, this);
			} 
		} 
	} 
 
    /** 
     * This method is invoked to signify that the Drag and Drop 
     * operation is complete. The getDropSuccess() method of 
3
CodeRank
This code example shows how to use the following methods:getTriggerEvent
     * <P> 
     * @param e the <code>DragGestureEvent</code> describing 
     * the gesture that has just occurred 
     */ 
	public void dragGestureRecognized(DragGestureEvent e) {
	    InputEvent in = e.getTriggerEvent();
	    if (in instanceof MouseEvent) {
			MouseEvent evt = (MouseEvent)in;
			boolean isLeftMouse = SwingUtilities.isLeftMouseButton(evt);
 
		    if (isLeftMouse && !evt.isAltDown()) {
				StringSelection text = new StringSelection(sIdentifier);
				this.requestFocus();
				dragSource.startDrag(e, DragSource.DefaultCopyDrop, text, this);
			} 
		} 
	} 
 
    /** 
     * This method is invoked to signify that the Drag and Drop 
3
CodeRank
See Code Examples for Java 8 DragGestureEvent Methods: