home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / dnd / DropTargetDropEvent.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.7 KB  |  132 lines

  1. /*
  2.  * @(#)DropTargetDropEvent.java    1.4 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.dnd;
  16.  
  17. import java.awt.Point;
  18.  
  19. import java.awt.datatransfer.DataFlavor;
  20. import java.awt.datatransfer.Transferable;
  21.  
  22. import java.awt.dnd.DropTargetEvent;
  23.  
  24. /**
  25.  * <p>
  26.  * The DropTargetDropEvent is delivered via the DropTargetListener drop() 
  27.  * method. 
  28.  * </p>
  29.  *
  30.  * @version 1.4
  31.  * @since JDK1.2
  32.  *
  33.  */
  34.  
  35. public class DropTargetDropEvent extends DropTargetEvent {
  36.  
  37.     /**
  38.      * Construct a DropTargetEvent
  39.      */
  40.  
  41.     public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions)  {
  42.     super(dtc);
  43.  
  44.     location        = cursorLocn;
  45.     actions         = srcActions;
  46.     this.dropAction = dropAction;
  47.     }
  48.  
  49.     /**
  50.      * Construct a DropTargetEvent
  51.      */
  52.  
  53.     public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions, boolean isLocal)  {
  54.     this(dtc, cursorLocn, srcActions, dropAction);
  55.  
  56.     isLocalTx = isLocal;
  57.     }
  58.  
  59.     /**
  60.      * @return the current cursor location in Component's coords.
  61.      */
  62.  
  63.     public Point getLocation() {
  64.     return location;
  65.     }
  66.  
  67.  
  68.     /**
  69.      * @return current DataFlavors
  70.      */
  71.  
  72.     public DataFlavor[] getCurrentDataFlavors() {
  73.     return context.getCurrentDataFlavors();
  74.     }
  75.  
  76.     /**
  77.      * @return source actions
  78.      */
  79.  
  80.     public int getSourceActions() { return actions; }
  81.  
  82.     /**
  83.      * @return source actions
  84.      */
  85.  
  86.     public int getDropAction() { return dropAction; }
  87.  
  88.     /**
  89.      * @return the Transferable associated with the drop
  90.      */
  91.  
  92.     public Transferable getTransferable() {
  93.     return getDropTargetContext().getTransferable();
  94.     }
  95.  
  96.     /**
  97.      * accept the Drop, using the specified operation.
  98.      */
  99.  
  100.     public void acceptDrop(int dropAction) {
  101.     getDropTargetContext().acceptDrop(dropAction);
  102.     }
  103.  
  104.     /**
  105.      * reject the Drop.
  106.      */
  107.  
  108.     public void rejectDrop() {
  109.     getDropTargetContext().rejectDrop();
  110.     }
  111.  
  112.     /**
  113.      * @return if the Source is in the same JVM
  114.      */
  115.  
  116.     public boolean isLocalTransfer() {
  117.     return isLocalTx;
  118.     }
  119.  
  120.     /*
  121.      * fields
  122.      */
  123.  
  124.     static final private Point  zero     = new Point(0,0);
  125.  
  126.     private Point        location   = zero;
  127.     private int            actions    = DnDConstants.ACTION_NONE;
  128.     private int            dropAction = DnDConstants.ACTION_NONE;
  129.  
  130.     private boolean            isLocalTx = false;
  131. }
  132.