< prev index next >

src/java.desktop/share/classes/java/awt/dnd/DragSourceDropEvent.java

Print this page




   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.awt.dnd;
  27 
  28 /**
  29  * The <code>DragSourceDropEvent</code> is delivered
  30  * from the <code>DragSourceContextPeer</code>,
  31  * via the <code>DragSourceContext</code>, to the <code>dragDropEnd</code>
  32  * method of <code>DragSourceListener</code>s registered with that
  33  * <code>DragSourceContext</code> and with its associated
  34  * <code>DragSource</code>.
  35  * It contains sufficient information for the
  36  * originator of the operation
  37  * to provide appropriate feedback to the end user
  38  * when the operation completes.
  39  *
  40  * @since 1.2
  41  */
  42 
  43 public class DragSourceDropEvent extends DragSourceEvent {
  44 
  45     private static final long serialVersionUID = -5571321229470821891L;
  46 
  47     /**
  48      * Construct a <code>DragSourceDropEvent</code> for a drop,
  49      * given the
  50      * <code>DragSourceContext</code>, the drop action,
  51      * and a <code>boolean</code> indicating if the drop was successful.
  52      * The coordinates for this <code>DragSourceDropEvent</code>
  53      * are not specified, so <code>getLocation</code> will return
  54      * <code>null</code> for this event.
  55      * <p>
  56      * The argument <code>action</code> should be one of <code>DnDConstants</code>
  57      * that represents a single action.
  58      * This constructor does not throw any exception for invalid <code>action</code>.
  59      *
  60      * @param dsc the <code>DragSourceContext</code>
  61      * associated with this <code>DragSourceDropEvent</code>
  62      * @param action the drop action
  63      * @param success a boolean indicating if the drop was successful
  64      *
  65      * @throws IllegalArgumentException if <code>dsc</code> is <code>null</code>.
  66      *
  67      * @see DragSourceEvent#getLocation
  68      */
  69 
  70     public DragSourceDropEvent(DragSourceContext dsc, int action, boolean success) {
  71         super(dsc);
  72 
  73         dropSuccess = success;
  74         dropAction  = action;
  75     }
  76 
  77     /**
  78      * Construct a <code>DragSourceDropEvent</code> for a drop, given the
  79      * <code>DragSourceContext</code>, the drop action, a <code>boolean</code>
  80      * indicating if the drop was successful, and coordinates.
  81      * <p>
  82      * The argument <code>action</code> should be one of <code>DnDConstants</code>
  83      * that represents a single action.
  84      * This constructor does not throw any exception for invalid <code>action</code>.
  85      *
  86      * @param dsc the <code>DragSourceContext</code>
  87      * associated with this <code>DragSourceDropEvent</code>
  88      * @param action the drop action
  89      * @param success a boolean indicating if the drop was successful
  90      * @param x   the horizontal coordinate for the cursor location
  91      * @param y   the vertical coordinate for the cursor location
  92      *
  93      * @throws IllegalArgumentException if <code>dsc</code> is <code>null</code>.
  94      *
  95      * @since 1.4
  96      */
  97     public DragSourceDropEvent(DragSourceContext dsc, int action,
  98                                boolean success, int x, int y) {
  99         super(dsc, x, y);
 100 
 101         dropSuccess = success;
 102         dropAction  = action;
 103     }
 104 
 105     /**
 106      * Construct a <code>DragSourceDropEvent</code>
 107      * for a drag that does not result in a drop.
 108      * The coordinates for this <code>DragSourceDropEvent</code>
 109      * are not specified, so <code>getLocation</code> will return
 110      * <code>null</code> for this event.
 111      *
 112      * @param dsc the <code>DragSourceContext</code>
 113      *
 114      * @throws IllegalArgumentException if <code>dsc</code> is <code>null</code>.
 115      *
 116      * @see DragSourceEvent#getLocation
 117      */
 118 
 119     public DragSourceDropEvent(DragSourceContext dsc) {
 120         super(dsc);
 121 
 122         dropSuccess = false;
 123     }
 124 
 125     /**
 126      * This method returns a <code>boolean</code> indicating
 127      * if the drop was successful.
 128      *
 129      * @return <code>true</code> if the drop target accepted the drop and
 130      *         successfully performed a drop action;
 131      *         <code>false</code> if the drop target rejected the drop or
 132      *         if the drop target accepted the drop, but failed to perform
 133      *         a drop action.
 134      */
 135 
 136     public boolean getDropSuccess() { return dropSuccess; }
 137 
 138     /**
 139      * This method returns an <code>int</code> representing
 140      * the action performed by the target on the subject of the drop.
 141      *
 142      * @return the action performed by the target on the subject of the drop
 143      *         if the drop target accepted the drop and the target drop action
 144      *         is supported by the drag source; otherwise,
 145      *         <code>DnDConstants.ACTION_NONE</code>.
 146      */
 147 
 148     public int getDropAction() { return dropAction; }
 149 
 150     /*
 151      * fields
 152      */
 153 
 154     /**
 155      * <code>true</code> if the drop was successful.
 156      *
 157      * @serial
 158      */
 159     private boolean dropSuccess;
 160 
 161     /**
 162      * The drop action.
 163      *
 164      * @serial
 165      */
 166     private int     dropAction   = DnDConstants.ACTION_NONE;
 167 }


   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.awt.dnd;
  27 
  28 /**
  29  * The {@code DragSourceDropEvent} is delivered
  30  * from the {@code DragSourceContextPeer},
  31  * via the {@code DragSourceContext}, to the {@code dragDropEnd}
  32  * method of {@code DragSourceListener}s registered with that
  33  * {@code DragSourceContext} and with its associated
  34  * {@code DragSource}.
  35  * It contains sufficient information for the
  36  * originator of the operation
  37  * to provide appropriate feedback to the end user
  38  * when the operation completes.
  39  *
  40  * @since 1.2
  41  */
  42 
  43 public class DragSourceDropEvent extends DragSourceEvent {
  44 
  45     private static final long serialVersionUID = -5571321229470821891L;
  46 
  47     /**
  48      * Construct a {@code DragSourceDropEvent} for a drop,
  49      * given the
  50      * {@code DragSourceContext}, the drop action,
  51      * and a {@code boolean} indicating if the drop was successful.
  52      * The coordinates for this {@code DragSourceDropEvent}
  53      * are not specified, so {@code getLocation} will return
  54      * {@code null} for this event.
  55      * <p>
  56      * The argument {@code action} should be one of {@code DnDConstants}
  57      * that represents a single action.
  58      * This constructor does not throw any exception for invalid {@code action}.
  59      *
  60      * @param dsc the {@code DragSourceContext}
  61      * associated with this {@code DragSourceDropEvent}
  62      * @param action the drop action
  63      * @param success a boolean indicating if the drop was successful
  64      *
  65      * @throws IllegalArgumentException if {@code dsc} is {@code null}.
  66      *
  67      * @see DragSourceEvent#getLocation
  68      */
  69 
  70     public DragSourceDropEvent(DragSourceContext dsc, int action, boolean success) {
  71         super(dsc);
  72 
  73         dropSuccess = success;
  74         dropAction  = action;
  75     }
  76 
  77     /**
  78      * Construct a {@code DragSourceDropEvent} for a drop, given the
  79      * {@code DragSourceContext}, the drop action, a {@code boolean}
  80      * indicating if the drop was successful, and coordinates.
  81      * <p>
  82      * The argument {@code action} should be one of {@code DnDConstants}
  83      * that represents a single action.
  84      * This constructor does not throw any exception for invalid {@code action}.
  85      *
  86      * @param dsc the {@code DragSourceContext}
  87      * associated with this {@code DragSourceDropEvent}
  88      * @param action the drop action
  89      * @param success a boolean indicating if the drop was successful
  90      * @param x   the horizontal coordinate for the cursor location
  91      * @param y   the vertical coordinate for the cursor location
  92      *
  93      * @throws IllegalArgumentException if {@code dsc} is {@code null}.
  94      *
  95      * @since 1.4
  96      */
  97     public DragSourceDropEvent(DragSourceContext dsc, int action,
  98                                boolean success, int x, int y) {
  99         super(dsc, x, y);
 100 
 101         dropSuccess = success;
 102         dropAction  = action;
 103     }
 104 
 105     /**
 106      * Construct a {@code DragSourceDropEvent}
 107      * for a drag that does not result in a drop.
 108      * The coordinates for this {@code DragSourceDropEvent}
 109      * are not specified, so {@code getLocation} will return
 110      * {@code null} for this event.
 111      *
 112      * @param dsc the {@code DragSourceContext}
 113      *
 114      * @throws IllegalArgumentException if {@code dsc} is {@code null}.
 115      *
 116      * @see DragSourceEvent#getLocation
 117      */
 118 
 119     public DragSourceDropEvent(DragSourceContext dsc) {
 120         super(dsc);
 121 
 122         dropSuccess = false;
 123     }
 124 
 125     /**
 126      * This method returns a {@code boolean} indicating
 127      * if the drop was successful.
 128      *
 129      * @return {@code true} if the drop target accepted the drop and
 130      *         successfully performed a drop action;
 131      *         {@code false} if the drop target rejected the drop or
 132      *         if the drop target accepted the drop, but failed to perform
 133      *         a drop action.
 134      */
 135 
 136     public boolean getDropSuccess() { return dropSuccess; }
 137 
 138     /**
 139      * This method returns an {@code int} representing
 140      * the action performed by the target on the subject of the drop.
 141      *
 142      * @return the action performed by the target on the subject of the drop
 143      *         if the drop target accepted the drop and the target drop action
 144      *         is supported by the drag source; otherwise,
 145      *         {@code DnDConstants.ACTION_NONE}.
 146      */
 147 
 148     public int getDropAction() { return dropAction; }
 149 
 150     /*
 151      * fields
 152      */
 153 
 154     /**
 155      * {@code true} if the drop was successful.
 156      *
 157      * @serial
 158      */
 159     private boolean dropSuccess;
 160 
 161     /**
 162      * The drop action.
 163      *
 164      * @serial
 165      */
 166     private int     dropAction   = DnDConstants.ACTION_NONE;
 167 }
< prev index next >