1 7 8 package java.awt.dnd; 9 10 import java.awt.Point ; 11 12 import java.awt.datatransfer.DataFlavor ; 13 import java.awt.datatransfer.Transferable ; 14 15 import java.util.List ; 16 17 54 55 public class DropTargetDropEvent extends DropTargetEvent { 56 57 private static final long serialVersionUID = -1721911170440459322L; 58 59 86 87 public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions) { 88 super(dtc); 89 90 if (cursorLocn == null) throw new NullPointerException ("cursorLocn"); 91 92 if (dropAction != DnDConstants.ACTION_NONE && 93 dropAction != DnDConstants.ACTION_COPY && 94 dropAction != DnDConstants.ACTION_MOVE && 95 dropAction != DnDConstants.ACTION_LINK 96 ) throw new IllegalArgumentException ("dropAction = " + dropAction); 97 98 if ((srcActions & ~(DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK)) != 0) throw new IllegalArgumentException ("srcActions"); 99 100 location = cursorLocn; 101 actions = srcActions; 102 this.dropAction = dropAction; 103 } 104 105 130 131 public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions, boolean isLocal) { 132 this(dtc, cursorLocn, dropAction, srcActions); 133 134 isLocalTx = isLocal; 135 } 136 137 144 145 public Point getLocation() { 146 return location; 147 } 148 149 150 155 156 public DataFlavor [] getCurrentDataFlavors() { 157 return getDropTargetContext().getCurrentDataFlavors(); 158 } 159 160 166 167 public List <DataFlavor > getCurrentDataFlavorsAsList() { 168 return getDropTargetContext().getCurrentDataFlavorsAsList(); 169 } 170 171 180 181 public boolean isDataFlavorSupported(DataFlavor df) { 182 return getDropTargetContext().isDataFlavorSupported(df); 183 } 184 185 190 public int getSourceActions() { return actions; } 191 192 197 public int getDropAction() { return dropAction; } 198 199 205 206 public Transferable getTransferable() { 207 return getDropTargetContext().getTransferable(); 208 } 209 210 215 216 public void acceptDrop(int dropAction) { 217 getDropTargetContext().acceptDrop(dropAction); 218 } 219 220 223 224 public void rejectDrop() { 225 getDropTargetContext().rejectDrop(); 226 } 227 228 234 235 public void dropComplete(boolean success) { 236 getDropTargetContext().dropComplete(success); 237 } 238 239 245 246 public boolean isLocalTransfer() { 247 return isLocalTx; 248 } 249 250 253 254 static final private Point zero = new Point (0,0); 255 256 261 private Point location = zero; 262 263 268 private int actions = DnDConstants.ACTION_NONE; 269 270 275 private int dropAction = DnDConstants.ACTION_NONE; 276 277 282 private boolean isLocalTx = false; 283 } 284 | Popular Tags |