List of usage examples for java.awt.dnd DragGestureEvent getDragOrigin
public Point getDragOrigin()
From source file:FileTreeDragSource.java
public void dragGestureRecognized(DragGestureEvent dge) { // Get the mouse location and convert it to // a location within the tree. Point location = dge.getDragOrigin(); TreePath dragPath = tree.getPathForLocation(location.x, location.y); if (dragPath != null && tree.isPathSelected(dragPath)) { // Get the list of selected files and create a Transferable // The list of files and the is saved for use when // the drop completes. paths = tree.getSelectionPaths(); if (paths != null && paths.length > 0) { dragFiles = new File[paths.length]; for (int i = 0; i < paths.length; i++) { String pathName = tree.getPathName(paths[i]); dragFiles[i] = new File(pathName); }//from ww w. ja v a2s . c om Transferable transferable = new FileListTransferable(dragFiles); dge.startDrag(null, transferable, this); } } }
From source file:org.jas.dnd.FileDragSource.java
@Override public void dragGestureRecognized(DragGestureEvent dge) { Point dragOrigin = dge.getDragOrigin(); List<File> draggedItems = fileSelection.selectedObjects(dragOrigin); if (draggedItems != null && !draggedItems.isEmpty()) { Transferable t = new FileTransferable(fileSelection.isFromExternalDevices(dragOrigin), draggedItems); try {//ww w . ja va2 s .com dragSource.startDrag(dge, DragSource.DefaultCopyDrop, t, this); } catch (InvalidDnDOperationException e) { LOG.error(e, e); } } }