java.awt.dnd.DragSourceListener Java Examples
The following examples show how to use
java.awt.dnd.DragSourceListener.
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: ImageTransferTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #2
Source File: ImageTransferTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #3
Source File: ImageTransferTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #4
Source File: ImageTransferTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #5
Source File: ImageTransferTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #6
Source File: ImageTransferTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #7
Source File: ImageTransferTest.java From hottub with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #8
Source File: ImageTransferTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #9
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void dragGestureRecognized(DragGestureEvent e) { try { e.startDrag(DragSource.DefaultMoveDrop, (Transferable) this, (DragSourceListener) this); } catch (InvalidDnDOperationException ex) { throw new IllegalStateException(ex); } }
Example #10
Source File: Button2DragTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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"); } }