148
149 public DragSource getDragSource() { return dragSource; }
150
151 /**
152 * Returns a <code>Point</code> in the coordinates
153 * of the <code>Component</code> over which the drag originated.
154 * <P>
155 * @return the Point where the drag originated in Component coords.
156 */
157
158 public Point getDragOrigin() {
159 return origin;
160 }
161
162 /**
163 * Returns an <code>Iterator</code> for the events
164 * comprising the gesture.
165 * <P>
166 * @return an Iterator for the events comprising the gesture
167 */
168
169 public Iterator<InputEvent> iterator() { return events.iterator(); }
170
171 /**
172 * Returns an <code>Object</code> array of the
173 * events comprising the drag gesture.
174 * <P>
175 * @return an array of the events comprising the gesture
176 */
177
178 public Object[] toArray() { return events.toArray(); }
179
180 /**
181 * Returns an array of the events comprising the drag gesture.
182 * <P>
183 * @param array the array of <code>EventObject</code> sub(types)
184 * <P>
185 * @return an array of the events comprising the gesture
186 */
187
188 public Object[] toArray(Object[] array) { return events.toArray(array); }
189
190 /**
191 * Returns an <code>int</code> representing the
192 * action selected by the user.
193 * <P>
194 * @return the action selected by the user
195 */
196
197 public int getDragAction() { return action; }
198
199 /**
200 * Returns the initial event that triggered the gesture.
201 * <P>
202 * @return the first "triggering" event in the sequence of the gesture
203 */
204
205 public InputEvent getTriggerEvent() {
206 return getSourceAsDragGestureRecognizer().getTriggerEvent();
207 }
316 * fields. An attempt is then made to deserialize this object's
317 * <code>List</code> of gesture events as well. This is first attempted
318 * by deserializing the field <code>events</code>, because, in releases
319 * prior to 1.4, a non-<code>transient</code> field of this name stored the
320 * <code>List</code> of gesture events. If this fails, the next object in
321 * the stream is used instead. If the resulting <code>List</code> is
322 * <code>null</code>, this object's <code>List</code> of gesture events
323 * is set to an empty <code>List</code>.
324 *
325 * @since 1.4
326 */
327 private void readObject(ObjectInputStream s)
328 throws ClassNotFoundException, IOException
329 {
330 ObjectInputStream.GetField f = s.readFields();
331
332 dragSource = (DragSource)f.get("dragSource", null);
333 component = (Component)f.get("component", null);
334 origin = (Point)f.get("origin", null);
335 action = f.get("action", 0);
336
337 // Pre-1.4 support. 'events' was previously non-transient
338 try {
339 events = (List)f.get("events", null);
340 } catch (IllegalArgumentException e) {
341 // 1.4-compatible byte stream. 'events' was written explicitly
342 events = (List)s.readObject();
343 }
344
345 // Implementation assumes 'events' is never null.
346 if (events == null) {
347 events = Collections.EMPTY_LIST;
348 }
349 }
350
351 /*
352 * fields
353 */
354
355 private transient List events;
356
357 /**
358 * The DragSource associated with this DragGestureEvent.
359 *
360 * @serial
361 */
362 private DragSource dragSource;
363
364 /**
365 * The Component associated with this DragGestureEvent.
366 *
367 * @serial
368 */
369 private Component component;
370
371 /**
372 * The origin of the drag.
373 *
374 * @serial
|
148
149 public DragSource getDragSource() { return dragSource; }
150
151 /**
152 * Returns a <code>Point</code> in the coordinates
153 * of the <code>Component</code> over which the drag originated.
154 * <P>
155 * @return the Point where the drag originated in Component coords.
156 */
157
158 public Point getDragOrigin() {
159 return origin;
160 }
161
162 /**
163 * Returns an <code>Iterator</code> for the events
164 * comprising the gesture.
165 * <P>
166 * @return an Iterator for the events comprising the gesture
167 */
168 @SuppressWarnings("unchecked")
169 public Iterator<InputEvent> iterator() { return events.iterator(); }
170
171 /**
172 * Returns an <code>Object</code> array of the
173 * events comprising the drag gesture.
174 * <P>
175 * @return an array of the events comprising the gesture
176 */
177
178 public Object[] toArray() { return events.toArray(); }
179
180 /**
181 * Returns an array of the events comprising the drag gesture.
182 * <P>
183 * @param array the array of <code>EventObject</code> sub(types)
184 * <P>
185 * @return an array of the events comprising the gesture
186 */
187 @SuppressWarnings("unchecked")
188 public Object[] toArray(Object[] array) { return events.toArray(array); }
189
190 /**
191 * Returns an <code>int</code> representing the
192 * action selected by the user.
193 * <P>
194 * @return the action selected by the user
195 */
196
197 public int getDragAction() { return action; }
198
199 /**
200 * Returns the initial event that triggered the gesture.
201 * <P>
202 * @return the first "triggering" event in the sequence of the gesture
203 */
204
205 public InputEvent getTriggerEvent() {
206 return getSourceAsDragGestureRecognizer().getTriggerEvent();
207 }
316 * fields. An attempt is then made to deserialize this object's
317 * <code>List</code> of gesture events as well. This is first attempted
318 * by deserializing the field <code>events</code>, because, in releases
319 * prior to 1.4, a non-<code>transient</code> field of this name stored the
320 * <code>List</code> of gesture events. If this fails, the next object in
321 * the stream is used instead. If the resulting <code>List</code> is
322 * <code>null</code>, this object's <code>List</code> of gesture events
323 * is set to an empty <code>List</code>.
324 *
325 * @since 1.4
326 */
327 private void readObject(ObjectInputStream s)
328 throws ClassNotFoundException, IOException
329 {
330 ObjectInputStream.GetField f = s.readFields();
331
332 dragSource = (DragSource)f.get("dragSource", null);
333 component = (Component)f.get("component", null);
334 origin = (Point)f.get("origin", null);
335 action = f.get("action", 0);
336 // Pre-1.4 support. 'events' was previously non-transient
337 try {
338 events = (List)f.get("events", null);
339 } catch (IllegalArgumentException e) {
340 // 1.4-compatible byte stream. 'events' was written explicitly
341 events = (List)s.readObject();
342 }
343
344 // Implementation assumes 'events' is never null.
345 if (events == null) {
346 events = Collections.EMPTY_LIST;
347 }
348 }
349
350 /*
351 * fields
352 */
353 @SuppressWarnings("rawtypes")
354 private transient List events;
355
356 /**
357 * The DragSource associated with this DragGestureEvent.
358 *
359 * @serial
360 */
361 private DragSource dragSource;
362
363 /**
364 * The Component associated with this DragGestureEvent.
365 *
366 * @serial
367 */
368 private Component component;
369
370 /**
371 * The origin of the drag.
372 *
373 * @serial
|