Java Code Examples for java.awt.dnd.DnDConstants#ACTION_COPY_OR_MOVE
The following examples show how to use
java.awt.dnd.DnDConstants#ACTION_COPY_OR_MOVE .
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: DragDropUtilities.java From netbeans with Apache License 2.0 | 6 votes |
/** Utility method. * @return true if given node supports given action, * false otherwise. */ static boolean checkNodeForAction(Node node, int dragAction) { if ( node.canCut() && ((dragAction == DnDConstants.ACTION_MOVE) || (dragAction == DnDConstants.ACTION_COPY_OR_MOVE)) ) { return true; } if ( node.canCopy() && ((dragAction == DnDConstants.ACTION_COPY) || (dragAction == DnDConstants.ACTION_COPY_OR_MOVE) || (dragAction == DnDConstants.ACTION_LINK) || (dragAction == DnDConstants.ACTION_REFERENCE)) ) { return true; } // hmmm, conditions not satisfied.. return false; }
Example 2
Source File: MissingEventsOnModalDialogTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Frame sourceFrame = createFrame("Source Frame", 0, 0); Frame targetFrame = createFrame("Target Frame", 250, 250); DragSource defaultDragSource = DragSource.getDefaultDragSource(); defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDragGestureListener()); new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDropTargetListener(targetFrame)); Robot robot = new Robot(); robot.setAutoDelay(50); sourceFrame.toFront(); robot.waitForIdle(); Point point = getCenterPoint(sourceFrame); robot.mouseMove(point.x, point.y); robot.waitForIdle(); mouseDragAndDrop(robot, point, getCenterPoint(targetFrame)); long time = System.currentTimeMillis() + 200; while (!passed) { if (time < System.currentTimeMillis()) { sourceFrame.dispose(); targetFrame.dispose(); throw new RuntimeException("Mouse clicked event is lost!"); } Thread.sleep(10); } sourceFrame.dispose(); targetFrame.dispose(); }
Example 3
Source File: MissingEventsOnModalDialogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Frame sourceFrame = createFrame("Source Frame", 0, 0); Frame targetFrame = createFrame("Target Frame", 250, 250); DragSource defaultDragSource = DragSource.getDefaultDragSource(); defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDragGestureListener()); new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDropTargetListener(targetFrame)); Robot robot = new Robot(); robot.setAutoDelay(50); sourceFrame.toFront(); robot.waitForIdle(); Point point = getCenterPoint(sourceFrame); robot.mouseMove(point.x, point.y); robot.waitForIdle(); mouseDragAndDrop(robot, point, getCenterPoint(targetFrame)); long time = System.currentTimeMillis() + 1000; while (!passed) { if (time < System.currentTimeMillis()) { sourceFrame.dispose(); targetFrame.dispose(); throw new RuntimeException("Mouse clicked event is lost!"); } Thread.sleep(10); } sourceFrame.dispose(); targetFrame.dispose(); }
Example 4
Source File: MissingEventsOnModalDialogTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Frame sourceFrame = createFrame("Source Frame", 0, 0); Frame targetFrame = createFrame("Target Frame", 250, 250); DragSource defaultDragSource = DragSource.getDefaultDragSource(); defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDragGestureListener()); new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDropTargetListener(targetFrame)); Robot robot = new Robot(); robot.setAutoDelay(50); sourceFrame.toFront(); robot.waitForIdle(); Point point = getCenterPoint(sourceFrame); robot.mouseMove(point.x, point.y); robot.waitForIdle(); mouseDragAndDrop(robot, point, getCenterPoint(targetFrame)); long time = System.currentTimeMillis() + 200; while (!passed) { if (time < System.currentTimeMillis()) { sourceFrame.dispose(); targetFrame.dispose(); throw new RuntimeException("Mouse clicked event is lost!"); } Thread.sleep(10); } sourceFrame.dispose(); targetFrame.dispose(); }
Example 5
Source File: WatchesNodeModel.java From netbeans with Apache License 2.0 | 5 votes |
public int getAllowedDropActions(Transferable t) { if (t != null && t.isDataFlavorSupported(new DataFlavor(Watch.class, null))) { return DnDConstants.ACTION_COPY_OR_MOVE; } else { return DnDConstants.ACTION_COPY; } }
Example 6
Source File: Trace.java From Method_Trace_Tool with Apache License 2.0 | 5 votes |
public static void drag()//定义的拖拽方法 { //panel表示要接受拖拽的控件 new DropTarget(JlPath, DnDConstants.ACTION_COPY_OR_MOVE, new DropTargetAdapter() { public void drop(DropTargetDropEvent dtde)//重写适配器的drop方法 { try { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor))//如果拖入的文件格式受支持 { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);//接收拖拽来的数据 List<File> list = (List<File>) (dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)); String temp = ""; for (File file : list) { temp = file.getAbsolutePath(); JlPath.setText(temp); break; } //JOptionPane.showMessageDialog(null, temp); dtde.dropComplete(true);//指示拖拽操作已完成 } else { dtde.rejectDrop();//否则拒绝拖拽来的数据 } } catch (Exception e) { e.printStackTrace(); } } }); }
Example 7
Source File: MissingEventsOnModalDialogTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Frame sourceFrame = createFrame("Source Frame", 0, 0); Frame targetFrame = createFrame("Target Frame", 250, 250); DragSource defaultDragSource = DragSource.getDefaultDragSource(); defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDragGestureListener()); new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDropTargetListener(targetFrame)); Robot robot = new Robot(); robot.setAutoDelay(50); sourceFrame.toFront(); robot.waitForIdle(); Point point = getCenterPoint(sourceFrame); robot.mouseMove(point.x, point.y); robot.waitForIdle(); mouseDragAndDrop(robot, point, getCenterPoint(targetFrame)); long time = System.currentTimeMillis() + 200; while (!passed) { if (time < System.currentTimeMillis()) { sourceFrame.dispose(); targetFrame.dispose(); throw new RuntimeException("Mouse clicked event is lost!"); } Thread.sleep(10); } sourceFrame.dispose(); targetFrame.dispose(); }
Example 8
Source File: AutoScrollingTreeDropTarget.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
AutoScrollingTreeDropTarget(JTree aTree, DropTargetListener listener) { super(aTree, DnDConstants.ACTION_COPY_OR_MOVE, listener); this.viewport = (JViewport) SwingUtilities.getAncestorOfClass( JViewport.class, aTree); this.scrollUnits = Math.max(aTree.getRowHeight(), 16); this.tree = aTree; }
Example 9
Source File: MissingEventsOnModalDialogTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Frame sourceFrame = createFrame("Source Frame", 0, 0); Frame targetFrame = createFrame("Target Frame", 250, 250); DragSource defaultDragSource = DragSource.getDefaultDragSource(); defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDragGestureListener()); new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE, new TestDropTargetListener(targetFrame)); Robot robot = new Robot(); robot.setAutoDelay(50); sourceFrame.toFront(); robot.waitForIdle(); Point point = getCenterPoint(sourceFrame); robot.mouseMove(point.x, point.y); robot.waitForIdle(); mouseDragAndDrop(robot, point, getCenterPoint(targetFrame)); long time = System.currentTimeMillis() + 200; while (!passed) { if (time < System.currentTimeMillis()) { sourceFrame.dispose(); targetFrame.dispose(); throw new RuntimeException("Mouse clicked event is lost!"); } Thread.sleep(10); } sourceFrame.dispose(); targetFrame.dispose(); }
Example 10
Source File: SunDropTargetContextPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * @param actions set the current actions */ public synchronized void setTargetActions(int actions) { currentA = actions & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); }
Example 11
Source File: SunDropTargetContextPeer.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * @param actions set the current actions */ public synchronized void setTargetActions(int actions) { currentA = actions & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); }
Example 12
Source File: SunDropTargetContextPeer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * @param actions set the current actions */ public synchronized void setTargetActions(int actions) { currentA = actions & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); }
Example 13
Source File: WatchesNodeModel.java From netbeans with Apache License 2.0 | 4 votes |
public int getAllowedDragActions() { return DnDConstants.ACTION_COPY_OR_MOVE; }
Example 14
Source File: DataTypeDragNDropHandler.java From ghidra with Apache License 2.0 | 4 votes |
@Override public int getSupportedDragActions() { return DnDConstants.ACTION_COPY_OR_MOVE; }
Example 15
Source File: SunDropTargetContextPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * @param actions set the current actions */ public synchronized void setTargetActions(int actions) { currentA = actions & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); }
Example 16
Source File: DataTreeDragNDropHandler.java From ghidra with Apache License 2.0 | 4 votes |
@Override public int getSupportedDragActions() { return DnDConstants.ACTION_COPY_OR_MOVE; }
Example 17
Source File: SunDropTargetContextPeer.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * @param actions set the current actions */ public synchronized void setTargetActions(int actions) { currentA = actions & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); }
Example 18
Source File: SunDropTargetContextPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * @param actions set the current actions */ public synchronized void setTargetActions(int actions) { currentA = actions & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); }
Example 19
Source File: SunDropTargetContextPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * @param actions set the current actions */ public synchronized void setTargetActions(int actions) { currentA = actions & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); }
Example 20
Source File: SunDropTargetContextPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * @param actions set the current actions */ public synchronized void setTargetActions(int actions) { currentA = actions & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK); }