< prev index next >
src/java.desktop/share/classes/java/awt/dnd/DragGestureEvent.java
Print this page
*** 47,62 ****
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
! * A <code>DragGestureEvent</code> is passed
! * to <code>DragGestureListener</code>'s
* dragGestureRecognized() method
! * when a particular <code>DragGestureRecognizer</code> detects that a
* platform dependent drag initiating gesture has occurred
! * on the <code>Component</code> that it is tracking.
*
* The {@code action} field of any {@code DragGestureEvent} instance should take one of the following
* values:
* <ul>
* <li> {@code DnDConstants.ACTION_COPY}
--- 47,62 ----
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
! * A {@code DragGestureEvent} is passed
! * to {@code DragGestureListener}'s
* dragGestureRecognized() method
! * when a particular {@code DragGestureRecognizer} detects that a
* platform dependent drag initiating gesture has occurred
! * on the {@code Component} that it is tracking.
*
* The {@code action} field of any {@code DragGestureEvent} instance should take one of the following
* values:
* <ul>
* <li> {@code DnDConstants.ACTION_COPY}
*** 74,96 ****
public class DragGestureEvent extends EventObject {
private static final long serialVersionUID = 9080172649166731306L;
/**
! * Constructs a <code>DragGestureEvent</code> object given by the
! * <code>DragGestureRecognizer</code> instance firing this event,
* an {@code act} parameter representing
* the user's preferred action, an {@code ori} parameter
* indicating the origin of the drag, and a {@code List} of
* events that comprise the gesture({@code evs} parameter).
*
! * @param dgr The <code>DragGestureRecognizer</code> firing this event
* @param act The user's preferred action.
* For information on allowable values, see
* the class description for {@link DragGestureEvent}
* @param ori The origin of the drag
! * @param evs The <code>List</code> of events that comprise the gesture
*
* @throws IllegalArgumentException if any parameter equals {@code null}
* @throws IllegalArgumentException if the act parameter does not comply with
* the values given in the class
* description for {@link DragGestureEvent}
--- 74,96 ----
public class DragGestureEvent extends EventObject {
private static final long serialVersionUID = 9080172649166731306L;
/**
! * Constructs a {@code DragGestureEvent} object given by the
! * {@code DragGestureRecognizer} instance firing this event,
* an {@code act} parameter representing
* the user's preferred action, an {@code ori} parameter
* indicating the origin of the drag, and a {@code List} of
* events that comprise the gesture({@code evs} parameter).
*
! * @param dgr The {@code DragGestureRecognizer} firing this event
* @param act The user's preferred action.
* For information on allowable values, see
* the class description for {@link DragGestureEvent}
* @param ori The origin of the drag
! * @param evs The {@code List} of events that comprise the gesture
*
* @throws IllegalArgumentException if any parameter equals {@code null}
* @throws IllegalArgumentException if the act parameter does not comply with
* the values given in the class
* description for {@link DragGestureEvent}
*** 121,197 ****
action = act;
origin = ori;
}
/**
! * Returns the source as a <code>DragGestureRecognizer</code>.
*
! * @return the source as a <code>DragGestureRecognizer</code>
*/
public DragGestureRecognizer getSourceAsDragGestureRecognizer() {
return (DragGestureRecognizer)getSource();
}
/**
! * Returns the <code>Component</code> associated
! * with this <code>DragGestureEvent</code>.
*
* @return the Component
*/
public Component getComponent() { return component; }
/**
! * Returns the <code>DragSource</code>.
*
! * @return the <code>DragSource</code>
*/
public DragSource getDragSource() { return dragSource; }
/**
! * Returns a <code>Point</code> in the coordinates
! * of the <code>Component</code> over which the drag originated.
*
* @return the Point where the drag originated in Component coords.
*/
public Point getDragOrigin() {
return origin;
}
/**
! * Returns an <code>Iterator</code> for the events
* comprising the gesture.
*
* @return an Iterator for the events comprising the gesture
*/
@SuppressWarnings("unchecked")
public Iterator<InputEvent> iterator() { return events.iterator(); }
/**
! * Returns an <code>Object</code> array of the
* events comprising the drag gesture.
*
* @return an array of the events comprising the gesture
*/
public Object[] toArray() { return events.toArray(); }
/**
* Returns an array of the events comprising the drag gesture.
*
! * @param array the array of <code>EventObject</code> sub(types)
*
* @return an array of the events comprising the gesture
*/
@SuppressWarnings("unchecked")
public Object[] toArray(Object[] array) { return events.toArray(array); }
/**
! * Returns an <code>int</code> representing the
* action selected by the user.
*
* @return the action selected by the user
*/
--- 121,197 ----
action = act;
origin = ori;
}
/**
! * Returns the source as a {@code DragGestureRecognizer}.
*
! * @return the source as a {@code DragGestureRecognizer}
*/
public DragGestureRecognizer getSourceAsDragGestureRecognizer() {
return (DragGestureRecognizer)getSource();
}
/**
! * Returns the {@code Component} associated
! * with this {@code DragGestureEvent}.
*
* @return the Component
*/
public Component getComponent() { return component; }
/**
! * Returns the {@code DragSource}.
*
! * @return the {@code DragSource}
*/
public DragSource getDragSource() { return dragSource; }
/**
! * Returns a {@code Point} in the coordinates
! * of the {@code Component} over which the drag originated.
*
* @return the Point where the drag originated in Component coords.
*/
public Point getDragOrigin() {
return origin;
}
/**
! * Returns an {@code Iterator} for the events
* comprising the gesture.
*
* @return an Iterator for the events comprising the gesture
*/
@SuppressWarnings("unchecked")
public Iterator<InputEvent> iterator() { return events.iterator(); }
/**
! * Returns an {@code Object} array of the
* events comprising the drag gesture.
*
* @return an array of the events comprising the gesture
*/
public Object[] toArray() { return events.toArray(); }
/**
* Returns an array of the events comprising the drag gesture.
*
! * @param array the array of {@code EventObject} sub(types)
*
* @return an array of the events comprising the gesture
*/
@SuppressWarnings("unchecked")
public Object[] toArray(Object[] array) { return events.toArray(array); }
/**
! * Returns an {@code int} representing the
* action selected by the user.
*
* @return the action selected by the user
*/
*** 206,231 ****
public InputEvent getTriggerEvent() {
return getSourceAsDragGestureRecognizer().getTriggerEvent();
}
/**
! * Starts the drag operation given the <code>Cursor</code> for this drag
! * operation and the <code>Transferable</code> representing the source data
* for this drag operation.
* <br>
! * If a <code>null</code> <code>Cursor</code> is specified no exception will
* be thrown and default drag cursors will be used instead.
* <br>
! * If a <code>null</code> <code>Transferable</code> is specified
! * <code>NullPointerException</code> will be thrown.
* @param dragCursor The initial {@code Cursor} for this drag operation
* or {@code null} for the default cursor handling;
* see
* <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
* for more details on the cursor handling mechanism
* during drag and drop
! * @param transferable The <code>Transferable</code> representing the source
* data for this drag operation.
*
* @throws InvalidDnDOperationException if the Drag and Drop
* system is unable to initiate a drag operation, or if the user
* attempts to start a drag while an existing drag operation is
--- 206,231 ----
public InputEvent getTriggerEvent() {
return getSourceAsDragGestureRecognizer().getTriggerEvent();
}
/**
! * Starts the drag operation given the {@code Cursor} for this drag
! * operation and the {@code Transferable} representing the source data
* for this drag operation.
* <br>
! * If a {@code null Cursor} is specified no exception will
* be thrown and default drag cursors will be used instead.
* <br>
! * If a {@code null Transferable} is specified
! * {@code NullPointerException} will be thrown.
* @param dragCursor The initial {@code Cursor} for this drag operation
* or {@code null} for the default cursor handling;
* see
* <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
* for more details on the cursor handling mechanism
* during drag and drop
! * @param transferable The {@code Transferable} representing the source
* data for this drag operation.
*
* @throws InvalidDnDOperationException if the Drag and Drop
* system is unable to initiate a drag operation, or if the user
* attempts to start a drag while an existing drag operation is
*** 237,249 ****
throws InvalidDnDOperationException {
dragSource.startDrag(this, dragCursor, transferable, null);
}
/**
! * Starts the drag given the initial <code>Cursor</code> to display,
! * the <code>Transferable</code> object,
! * and the <code>DragSourceListener</code> to use.
*
* @param dragCursor The initial {@code Cursor} for this drag operation
* or {@code null} for the default cursor handling;
* see
* <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
--- 237,249 ----
throws InvalidDnDOperationException {
dragSource.startDrag(this, dragCursor, transferable, null);
}
/**
! * Starts the drag given the initial {@code Cursor} to display,
! * the {@code Transferable} object,
! * and the {@code DragSourceListener} to use.
*
* @param dragCursor The initial {@code Cursor} for this drag operation
* or {@code null} for the default cursor handling;
* see
* <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
*** 262,276 ****
public void startDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException {
dragSource.startDrag(this, dragCursor, transferable, dsl);
}
/**
! * Start the drag given the initial <code>Cursor</code> to display,
! * a drag <code>Image</code>, the offset of
! * the <code>Image</code>,
! * the <code>Transferable</code> object, and
! * the <code>DragSourceListener</code> to use.
*
* @param dragCursor The initial {@code Cursor} for this drag operation
* or {@code null} for the default cursor handling;
* see
* <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
--- 262,276 ----
public void startDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException {
dragSource.startDrag(this, dragCursor, transferable, dsl);
}
/**
! * Start the drag given the initial {@code Cursor} to display,
! * a drag {@code Image}, the offset of
! * the {@code Image},
! * the {@code Transferable} object, and
! * the {@code DragSourceListener} to use.
*
* @param dragCursor The initial {@code Cursor} for this drag operation
* or {@code null} for the default cursor handling;
* see
* <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
*** 291,329 ****
public void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException {
dragSource.startDrag(this, dragCursor, dragImage, imageOffset, transferable, dsl);
}
/**
! * Serializes this <code>DragGestureEvent</code>. Performs default
! * serialization and then writes out this object's <code>List</code> of
! * gesture events if and only if the <code>List</code> can be serialized.
! * If not, <code>null</code> is written instead. In this case, a
! * <code>DragGestureEvent</code> created from the resulting deserialized
! * stream will contain an empty <code>List</code> of gesture events.
*
* @serialData The default serializable fields, in alphabetical order,
! * followed by either a <code>List</code> instance, or
! * <code>null</code>.
* @since 1.4
*/
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
s.writeObject(SerializationTester.test(events) ? events : null);
}
/**
! * Deserializes this <code>DragGestureEvent</code>. This method first
! * performs default deserialization for all non-<code>transient</code>
* fields. An attempt is then made to deserialize this object's
! * <code>List</code> of gesture events as well. This is first attempted
! * by deserializing the field <code>events</code>, because, in releases
! * prior to 1.4, a non-<code>transient</code> field of this name stored the
! * <code>List</code> of gesture events. If this fails, the next object in
! * the stream is used instead. If the resulting <code>List</code> is
! * <code>null</code>, this object's <code>List</code> of gesture events
! * is set to an empty <code>List</code>.
*
* @since 1.4
*/
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException
--- 291,329 ----
public void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException {
dragSource.startDrag(this, dragCursor, dragImage, imageOffset, transferable, dsl);
}
/**
! * Serializes this {@code DragGestureEvent}. Performs default
! * serialization and then writes out this object's {@code List} of
! * gesture events if and only if the {@code List} can be serialized.
! * If not, {@code null} is written instead. In this case, a
! * {@code DragGestureEvent} created from the resulting deserialized
! * stream will contain an empty {@code List} of gesture events.
*
* @serialData The default serializable fields, in alphabetical order,
! * followed by either a {@code List} instance, or
! * {@code null}.
* @since 1.4
*/
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
s.writeObject(SerializationTester.test(events) ? events : null);
}
/**
! * Deserializes this {@code DragGestureEvent}. This method first
! * performs default deserialization for all non-{@code transient}
* fields. An attempt is then made to deserialize this object's
! * {@code List} of gesture events as well. This is first attempted
! * by deserializing the field {@code events}, because, in releases
! * prior to 1.4, a non-{@code transient} field of this name stored the
! * {@code List} of gesture events. If this fails, the next object in
! * the stream is used instead. If the resulting {@code List} is
! * {@code null}, this object's {@code List} of gesture events
! * is set to an empty {@code List}.
*
* @since 1.4
*/
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException
< prev index next >