KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > dnd > DragSourceDropEvent


1 /*
2  * @(#)DragSourceDropEvent.java 1.19 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.awt.dnd;
9
10 /**
11  * The <code>DragSourceDropEvent</code> is delivered
12  * from the <code>DragSourceContextPeer</code>,
13  * via the <code>DragSourceContext</code>, to the <code>dragDropEnd</code>
14  * method of <code>DragSourceListener</code>s registered with that
15  * <code>DragSourceContext</code> and with its associated
16  * <code>DragSource</code>.
17  * It contains sufficient information for the
18  * originator of the operation
19  * to provide appropriate feedback to the end user
20  * when the operation completes.
21  * <P>
22  * @version 1.19, 12/19/03
23  * <P>
24  * @since 1.2
25  */

26
27 public class DragSourceDropEvent extends DragSourceEvent JavaDoc {
28
29     private static final long serialVersionUID = -5571321229470821891L;
30
31     /**
32      * Construct a <code>DragSourceDropEvent</code> for a drop,
33      * given the
34      * <code>DragSourceContext</code>, the drop action,
35      * and a <code>boolean</code> indicating if the drop was successful.
36      * The coordinates for this <code>DragSourceDropEvent</code>
37      * are not specified, so <code>getLocation</code> will return
38      * <code>null</code> for this event.
39      * <p>
40      * The argument <code>action</code> should be one of <code>DnDConstants</code>
41      * that represents a single action.
42      * This constructor does not throw any exception for invalid <code>action</code>.
43      *
44      * @param dsc the <code>DragSourceContext</code>
45      * associated with this <code>DragSourceDropEvent</code>
46      * @param action the drop action
47      * @param success a boolean indicating if the drop was successful
48      *
49      * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
50      *
51      * @see DragSourceEvent#getLocation
52      */

53
54     public DragSourceDropEvent(DragSourceContext JavaDoc dsc, int action, boolean success) {
55     super(dsc);
56
57     dropSuccess = success;
58     dropAction = action;
59     }
60
61     /**
62      * Construct a <code>DragSourceDropEvent</code> for a drop, given the
63      * <code>DragSourceContext</code>, the drop action, a <code>boolean</code>
64      * indicating if the drop was successful, and coordinates.
65      * <p>
66      * The argument <code>action</code> should be one of <code>DnDConstants</code>
67      * that represents a single action.
68      * This constructor does not throw any exception for invalid <code>action</code>.
69      *
70      * @param dsc the <code>DragSourceContext</code>
71      * associated with this <code>DragSourceDropEvent</code>
72      * @param action the drop action
73      * @param success a boolean indicating if the drop was successful
74      * @param x the horizontal coordinate for the cursor location
75      * @param y the vertical coordinate for the cursor location
76      *
77      * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
78      *
79      * @since 1.4
80      */

81     public DragSourceDropEvent(DragSourceContext JavaDoc dsc, int action,
82                                boolean success, int x, int y) {
83         super(dsc, x, y);
84
85         dropSuccess = success;
86         dropAction = action;
87     }
88
89     /**
90      * Construct a <code>DragSourceDropEvent</code>
91      * for a drag that does not result in a drop.
92      * The coordinates for this <code>DragSourceDropEvent</code>
93      * are not specified, so <code>getLocation</code> will return
94      * <code>null</code> for this event.
95      *
96      * @param dsc the <code>DragSourceContext</code>
97      *
98      * @throws <code>IllegalArgumentException</code> if <code>dsc</code> is <code>null</code>.
99      *
100      * @see DragSourceEvent#getLocation
101      */

102
103     public DragSourceDropEvent(DragSourceContext JavaDoc dsc) {
104     super(dsc);
105
106     dropSuccess = false;
107     }
108
109     /**
110      * This method returns a <code>boolean</code> indicating
111      * if the drop was successful.
112      *
113      * @return <code>true</code> if the drop target accepted the drop and
114      * successfully performed a drop action;
115      * <code>false</code> if the drop target rejected the drop or
116      * if the drop target accepted the drop, but failed to perform
117      * a drop action.
118      */

119
120     public boolean getDropSuccess() { return dropSuccess; }
121
122     /**
123      * This method returns an <code>int</code> representing
124      * the action performed by the target on the subject of the drop.
125      *
126      * @return the action performed by the target on the subject of the drop
127      * if the drop target accepted the drop and the target drop action
128      * is supported by the drag source; otherwise,
129      * <code>DnDConstants.ACTION_NONE</code>.
130      */

131
132     public int getDropAction() { return dropAction; }
133
134     /*
135      * fields
136      */

137
138     /**
139      * <code>true</code> if the drop was successful.
140      *
141      * @serial
142      */

143     private boolean dropSuccess;
144
145     /**
146      * The drop action.
147      *
148      * @serial
149      */

150     private int dropAction = DnDConstants.ACTION_NONE;
151 }
152
Popular Tags