Java Code Examples for java.awt.dnd.DragGestureEvent#startDrag()

The following examples show how to use java.awt.dnd.DragGestureEvent#startDrag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryGlobalSearchGUIProvider.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void dragGestureRecognized(DragGestureEvent event) {
	// only allow dragging with left mouse button
	if (event.getTriggerEvent().getModifiers() != InputEvent.BUTTON1_MASK) {
		return;
	}

	// change cursor to drag move
	Cursor cursor = null;
	if (event.getDragAction() == DnDConstants.ACTION_COPY) {
		cursor = DragSource.DefaultCopyDrop;
	}

	// set the repository entry as the Transferable
	TransferableRepositoryEntry transferable = new TransferableRepositoryEntry(location);
	if (usageLogger != null) {
		transferable.setUsageStatsLogger(usageLogger);
	} else if (usageObject != null) {
		transferable.setUsageObject(usageObject);
	}
	event.startDrag(cursor, transferable);
}
 
Example 2
Source File: SourceFileListFrame.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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)));
}
 
Example 3
Source File: SourceFileListFrame.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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)));
}
 
Example 4
Source File: SourceFileListFrame.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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)));
}
 
Example 5
Source File: SourceFileListFrame.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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));
}
 
Example 6
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@Override public void dragGestureRecognized(DragGestureEvent e) {
  boolean isMoreThanOneRowSelected = getSelectedRowCount() > 1;
  if (isMoreThanOneRowSelected) {
    return;
  }
  draggedIndex = rowAtPoint(e.getDragOrigin());
  if (draggedIndex < 0) {
    return;
  }
  try {
    e.startDrag(DragSource.DefaultMoveDrop, (Transferable) this, new TableDragSourceListener());
  } catch (InvalidDnDOperationException ex) {
    throw new IllegalStateException(ex);
  }
}
 
Example 7
Source File: SourceFileListFrame.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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));
}
 
Example 8
Source File: SourcePanel.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new FileListTransferable());
}
 
Example 9
Source File: SourcePanel.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new MyTransferable());
}
 
Example 10
Source File: MissedDragExitTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(Cursor.getDefaultCursor(), new StringSelection("test"));
}
 
Example 11
Source File: Button2DragTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    frame = new Frame();

    final DragSourceListener dragSourceListener = new DragSourceAdapter() {
        public void dragDropEnd(DragSourceDropEvent e) {
            dropSuccess = e.getDropSuccess();
            System.err.println("Drop was successful: " + dropSuccess);
        }
    };
    DragGestureListener dragGestureListener = new DragGestureListener() {
        public void dragGestureRecognized(DragGestureEvent dge) {
            dge.startDrag(null, new StringSelection("OK"), dragSourceListener);
        }
    };
    new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_MOVE,
                                                        dragGestureListener);

    DropTargetAdapter dropTargetListener = new DropTargetAdapter() {
        public void drop(DropTargetDropEvent dtde) {
            dtde.acceptDrop(DnDConstants.ACTION_MOVE);
            dtde.dropComplete(true);
            System.err.println("Drop");
        }
    };
    new DropTarget(frame, dropTargetListener);

    //What would normally go into main() will probably go here.
    //Use System.out.println for diagnostic messages that you want
    //to read after the test is done.
    frame.setUndecorated(true);
    frame.setBounds(100, 100, 200, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    Robot robot = Util.createRobot();

    Util.waitForIdle(robot);

    Point startPoint = frame.getLocationOnScreen();
    Point endPoint = new Point(startPoint);
    startPoint.translate(50, 50);
    endPoint.translate(150, 150);

    Util.drag(robot, startPoint, endPoint, InputEvent.BUTTON2_MASK);

    Util.waitForIdle(robot);
    robot.delay(500);

    if (dropSuccess) {
        System.err.println("test passed");
    } else {
        throw new RuntimeException("test failed: drop was not successful");
    }
}
 
Example 12
Source File: MissingEventsOnModalDialogTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new StringTransferable());
}
 
Example 13
Source File: MissedDragExitTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(Cursor.getDefaultCursor(), new StringSelection("test"));
}
 
Example 14
Source File: SourceFrame.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new StringSelection("A TEXT"));
}
 
Example 15
Source File: SourcePanel.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new FileListTransferable());
}
 
Example 16
Source File: SourcePanel.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new MyTransferable());
}
 
Example 17
Source File: MissedDragExitTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(Cursor.getDefaultCursor(), new StringSelection("test"));
}
 
Example 18
Source File: SourcePanel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new FileListTransferable());
}
 
Example 19
Source File: SourceFrame.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new StringSelection("A TEXT"));
}
 
Example 20
Source File: SourcePanel.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {
    dge.startDrag(null, new FileListTransferable());
}