List of usage examples for java.awt.dnd DropTargetDragEvent getDropTargetContext
public DropTargetContext getDropTargetContext()
From source file:TreeDragTest.java
private TreeNode getNodeForEvent(DropTargetDragEvent dtde) { Point p = dtde.getLocation(); DropTargetContext dtc = dtde.getDropTargetContext(); JTree tree = (JTree) dtc.getComponent(); TreePath path = tree.getClosestPathForLocation(p.x, p.y); return (TreeNode) path.getLastPathComponent(); }
From source file:org.jas.dnd.MultiLayerDropTargetListener.java
@Override public void dragEnter(DropTargetDragEvent dtde) { getDragAction().dragExit();//from w w w. j a v a 2s .com lastDropSuccess = false; Window window = null; Component component; Component component2 = component = dtde.getDropTargetContext().getComponent(); while (window == null && component != null) { if (component instanceof Window) { window = (Window) component; } else { component = component.getParent(); } } Container currentTriggerFrame = null; if (window == null) { if (component2 instanceof Container) { currentTriggerFrame = (Container) component2; } else { currentTriggerFrame = component2.getParent(); } } else { currentTriggerFrame = window; } getDragAction(currentTriggerFrame); dragOver(dtde); }
From source file:de.tor.tribes.ui.algo.AttackTimePanel.java
@Override public void dragEnter(DropTargetDragEvent dtde) { if (dtde.getDropTargetContext().getComponent().equals(jTimeFrameList)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); }//w w w .ja va2 s. co m }
From source file:de.tor.tribes.ui.algo.AttackTimePanel.java
@Override public void dragOver(DropTargetDragEvent dtde) { if (dtde.getDropTargetContext().getComponent().equals(jTimeFrameList)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); }/*from ww w . j a v a 2 s . c o m*/ }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
@Override public void dragEnter(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) { if (dtde.getDropTargetContext().getComponent() == jSourcesTable || dtde.getDropTargetContext().getComponent() == jVictimTable) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else {/* w w w . j a v a 2s.c o m*/ dtde.rejectDrag(); } } else { dtde.rejectDrag(); } }