< prev index next >
src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java
Print this page
@@ -44,26 +44,26 @@
import sun.awt.AWTAccessor;
import sun.awt.ComponentFactory;
/**
- * The <code>DragSourceContext</code> class is responsible for managing the
+ * The {@code DragSourceContext} class is responsible for managing the
* initiator side of the Drag and Drop protocol. In particular, it is responsible
* for managing drag event notifications to the
* {@linkplain DragSourceListener DragSourceListeners}
* and {@linkplain DragSourceMotionListener DragSourceMotionListeners}, and providing the
* {@link Transferable} representing the source data for the drag operation.
* <p>
- * Note that the <code>DragSourceContext</code> itself
- * implements the <code>DragSourceListener</code> and
- * <code>DragSourceMotionListener</code> interfaces.
+ * Note that the {@code DragSourceContext} itself
+ * implements the {@code DragSourceListener} and
+ * {@code DragSourceMotionListener} interfaces.
* This is to allow the platform peer
* (the {@link DragSourceContextPeer} instance)
* created by the {@link DragSource} to notify
- * the <code>DragSourceContext</code> of
+ * the {@code DragSourceContext} of
* state changes in the ongoing operation. This allows the
- * <code>DragSourceContext</code> object to interpose
+ * {@code DragSourceContext} object to interpose
* itself between the platform and the
* listeners provided by the initiator of the drag operation.
* <p>
* <a name="defaultCursor"></a>
* By default, {@code DragSourceContext} sets the cursor as appropriate
@@ -95,93 +95,93 @@
private static final long serialVersionUID = -115407898692194719L;
// used by updateCurrentCursor
/**
- * An <code>int</code> used by updateCurrentCursor()
- * indicating that the <code>Cursor</code> should change
- * to the default (no drop) <code>Cursor</code>.
+ * An {@code int} used by updateCurrentCursor()
+ * indicating that the {@code Cursor} should change
+ * to the default (no drop) {@code Cursor}.
*/
protected static final int DEFAULT = 0;
/**
- * An <code>int</code> used by updateCurrentCursor()
- * indicating that the <code>Cursor</code>
- * has entered a <code>DropTarget</code>.
+ * An {@code int} used by updateCurrentCursor()
+ * indicating that the {@code Cursor}
+ * has entered a {@code DropTarget}.
*/
protected static final int ENTER = 1;
/**
- * An <code>int</code> used by updateCurrentCursor()
- * indicating that the <code>Cursor</code> is
- * over a <code>DropTarget</code>.
+ * An {@code int} used by updateCurrentCursor()
+ * indicating that the {@code Cursor} is
+ * over a {@code DropTarget}.
*/
protected static final int OVER = 2;
/**
- * An <code>int</code> used by updateCurrentCursor()
+ * An {@code int} used by updateCurrentCursor()
* indicating that the user operation has changed.
*/
protected static final int CHANGED = 3;
static {
AWTAccessor.setDragSourceContextAccessor(dsc -> dsc.peer);
}
/**
- * Called from <code>DragSource</code>, this constructor creates a new
- * <code>DragSourceContext</code> given the
- * <code>DragSourceContextPeer</code> for this Drag, the
- * <code>DragGestureEvent</code> that triggered the Drag, the initial
- * <code>Cursor</code> to use for the Drag, an (optional)
- * <code>Image</code> to display while the Drag is taking place, the offset
- * of the <code>Image</code> origin from the hotspot at the instant of the
- * triggering event, the <code>Transferable</code> subject data, and the
- * <code>DragSourceListener</code> to use during the Drag and Drop
+ * Called from {@code DragSource}, this constructor creates a new
+ * {@code DragSourceContext} given the
+ * {@code DragSourceContextPeer} for this Drag, the
+ * {@code DragGestureEvent} that triggered the Drag, the initial
+ * {@code Cursor} to use for the Drag, an (optional)
+ * {@code Image} to display while the Drag is taking place, the offset
+ * of the {@code Image} origin from the hotspot at the instant of the
+ * triggering event, the {@code Transferable} subject data, and the
+ * {@code DragSourceListener} to use during the Drag and Drop
* operation.
* <br>
- * If <code>DragSourceContextPeer</code> is <code>null</code>
- * <code>NullPointerException</code> is thrown.
+ * If {@code DragSourceContextPeer} is {@code null}
+ * {@code NullPointerException} is thrown.
* <br>
- * If <code>DragGestureEvent</code> is <code>null</code>
- * <code>NullPointerException</code> is thrown.
+ * If {@code DragGestureEvent} is {@code null}
+ * {@code NullPointerException} is thrown.
* <br>
- * If <code>Cursor</code> is <code>null</code> no exception is thrown and
+ * If {@code Cursor} is {@code null} no exception is thrown and
* the default drag cursor behavior is activated for this drag operation.
* <br>
- * If <code>Image</code> is <code>null</code> no exception is thrown.
+ * If {@code Image} is {@code null} no exception is thrown.
* <br>
- * If <code>Image</code> is not <code>null</code> and the offset is
- * <code>null</code> <code>NullPointerException</code> is thrown.
+ * If {@code Image} is not {@code null} and the offset is
+ * {@code null NullPointerException} is thrown.
* <br>
- * If <code>Transferable</code> is <code>null</code>
- * <code>NullPointerException</code> is thrown.
+ * If {@code Transferable} is {@code null}
+ * {@code NullPointerException} is thrown.
* <br>
- * If <code>DragSourceListener</code> is <code>null</code> no exception
+ * If {@code DragSourceListener} is {@code null} no exception
* is thrown.
*
* @param trigger the triggering event
* @param dragCursor the initial {@code Cursor} for this drag operation
* or {@code null} for the default cursor handling;
* see <a href="DragSourceContext.html#defaultCursor">class level documentation</a>
* for more details on the cursor handling mechanism during drag and drop
- * @param dragImage the <code>Image</code> to drag (or <code>null</code>)
+ * @param dragImage the {@code Image} to drag (or {@code null})
* @param offset the offset of the image origin from the hotspot at the
* instant of the triggering event
- * @param t the <code>Transferable</code>
- * @param dsl the <code>DragSourceListener</code>
+ * @param t the {@code Transferable}
+ * @param dsl the {@code DragSourceListener}
*
- * @throws IllegalArgumentException if the <code>Component</code> associated
- * with the trigger event is <code>null</code>.
- * @throws IllegalArgumentException if the <code>DragSource</code> for the
- * trigger event is <code>null</code>.
+ * @throws IllegalArgumentException if the {@code Component} associated
+ * with the trigger event is {@code null}.
+ * @throws IllegalArgumentException if the {@code DragSource} for the
+ * trigger event is {@code null}.
* @throws IllegalArgumentException if the drag action for the
- * trigger event is <code>DnDConstants.ACTION_NONE</code>.
+ * trigger event is {@code DnDConstants.ACTION_NONE}.
* @throws IllegalArgumentException if the source actions for the
- * <code>DragGestureRecognizer</code> associated with the trigger
- * event are equal to <code>DnDConstants.ACTION_NONE</code>.
+ * {@code DragGestureRecognizer} associated with the trigger
+ * event are equal to {@code DnDConstants.ACTION_NONE}.
* @throws NullPointerException if dscp, trigger, or t are null, or
* if dragImage is non-null and offset is null
*/
public DragSourceContext(DragGestureEvent trigger, Cursor dragCursor,
Image dragImage, Point offset, Transferable t,
@@ -238,52 +238,52 @@
updateCurrentCursor(trigger.getDragAction(), getSourceActions(), DEFAULT);
}
/**
- * Returns the <code>DragSource</code>
- * that instantiated this <code>DragSourceContext</code>.
+ * Returns the {@code DragSource}
+ * that instantiated this {@code DragSourceContext}.
*
- * @return the <code>DragSource</code> that
- * instantiated this <code>DragSourceContext</code>
+ * @return the {@code DragSource} that
+ * instantiated this {@code DragSourceContext}
*/
public DragSource getDragSource() { return trigger.getDragSource(); }
/**
- * Returns the <code>Component</code> associated with this
- * <code>DragSourceContext</code>.
+ * Returns the {@code Component} associated with this
+ * {@code DragSourceContext}.
*
- * @return the <code>Component</code> that started the drag
+ * @return the {@code Component} that started the drag
*/
public Component getComponent() { return trigger.getComponent(); }
/**
- * Returns the <code>DragGestureEvent</code>
+ * Returns the {@code DragGestureEvent}
* that initially triggered the drag.
*
* @return the Event that triggered the drag
*/
public DragGestureEvent getTrigger() { return trigger; }
/**
- * Returns a bitwise mask of <code>DnDConstants</code> that
+ * Returns a bitwise mask of {@code DnDConstants} that
* represent the set of drop actions supported by the drag source for the
- * drag operation associated with this <code>DragSourceContext</code>.
+ * drag operation associated with this {@code DragSourceContext}.
*
* @return the drop actions supported by the drag source
*/
public int getSourceActions() {
return sourceActions;
}
/**
* Sets the cursor for this drag operation to the specified
- * <code>Cursor</code>. If the specified <code>Cursor</code>
- * is <code>null</code>, the default drag cursor behavior is
+ * {@code Cursor}. If the specified {@code Cursor}
+ * is {@code null}, the default drag cursor behavior is
* activated for this drag operation, otherwise it is deactivated.
*
* @param c the initial {@code Cursor} for this drag operation,
* or {@code null} for the default cursor handling;
* see {@linkplain Cursor class
@@ -296,29 +296,29 @@
useCustomCursor = (c != null);
setCursorImpl(c);
}
/**
- * Returns the current drag <code>Cursor</code>.
+ * Returns the current drag {@code Cursor}.
*
- * @return the current drag <code>Cursor</code>
+ * @return the current drag {@code Cursor}
*/
public Cursor getCursor() { return cursor; }
/**
- * Add a <code>DragSourceListener</code> to this
- * <code>DragSourceContext</code> if one has not already been added.
- * If a <code>DragSourceListener</code> already exists,
- * this method throws a <code>TooManyListenersException</code>.
+ * Add a {@code DragSourceListener} to this
+ * {@code DragSourceContext} if one has not already been added.
+ * If a {@code DragSourceListener} already exists,
+ * this method throws a {@code TooManyListenersException}.
*
- * @param dsl the <code>DragSourceListener</code> to add.
- * Note that while <code>null</code> is not prohibited,
+ * @param dsl the {@code DragSourceListener} to add.
+ * Note that while {@code null} is not prohibited,
* it is not acceptable as a parameter.
*
* @throws TooManyListenersException if
- * a <code>DragSourceListener</code> has already been added
+ * a {@code DragSourceListener} has already been added
*/
public synchronized void addDragSourceListener(DragSourceListener dsl) throws TooManyListenersException {
if (dsl == null) return;
@@ -329,15 +329,15 @@
else
listener = dsl;
}
/**
- * Removes the specified <code>DragSourceListener</code>
- * from this <code>DragSourceContext</code>.
+ * Removes the specified {@code DragSourceListener}
+ * from this {@code DragSourceContext}.
*
- * @param dsl the <code>DragSourceListener</code> to remove;
- * note that while <code>null</code> is not prohibited,
+ * @param dsl the {@code DragSourceListener} to remove;
+ * note that while {@code null} is not prohibited,
* it is not acceptable as a parameter
*/
public synchronized void removeDragSourceListener(DragSourceListener dsl) {
if (listener != null && listener.equals(dsl)) {
@@ -345,26 +345,26 @@
} else
throw new IllegalArgumentException();
}
/**
- * Notifies the peer that the <code>Transferable</code>'s
- * <code>DataFlavor</code>s have changed.
+ * Notifies the peer that the {@code Transferable}'s
+ * {@code DataFlavor}s have changed.
*/
public void transferablesFlavorsChanged() {
if (peer != null) peer.transferablesFlavorsChanged();
}
/**
- * Calls <code>dragEnter</code> on the
- * <code>DragSourceListener</code>s registered with this
- * <code>DragSourceContext</code> and with the associated
- * <code>DragSource</code>, and passes them the specified
- * <code>DragSourceDragEvent</code>.
+ * Calls {@code dragEnter} on the
+ * {@code DragSourceListener}s registered with this
+ * {@code DragSourceContext} and with the associated
+ * {@code DragSource}, and passes them the specified
+ * {@code DragSourceDragEvent}.
*
- * @param dsde the <code>DragSourceDragEvent</code>
+ * @param dsde the {@code DragSourceDragEvent}
*/
public void dragEnter(DragSourceDragEvent dsde) {
DragSourceListener dsl = listener;
if (dsl != null) {
dsl.dragEnter(dsde);
@@ -373,17 +373,17 @@
updateCurrentCursor(getSourceActions(), dsde.getTargetActions(), ENTER);
}
/**
- * Calls <code>dragOver</code> on the
- * <code>DragSourceListener</code>s registered with this
- * <code>DragSourceContext</code> and with the associated
- * <code>DragSource</code>, and passes them the specified
- * <code>DragSourceDragEvent</code>.
+ * Calls {@code dragOver} on the
+ * {@code DragSourceListener}s registered with this
+ * {@code DragSourceContext} and with the associated
+ * {@code DragSource}, and passes them the specified
+ * {@code DragSourceDragEvent}.
*
- * @param dsde the <code>DragSourceDragEvent</code>
+ * @param dsde the {@code DragSourceDragEvent}
*/
public void dragOver(DragSourceDragEvent dsde) {
DragSourceListener dsl = listener;
if (dsl != null) {
dsl.dragOver(dsde);
@@ -392,17 +392,17 @@
updateCurrentCursor(getSourceActions(), dsde.getTargetActions(), OVER);
}
/**
- * Calls <code>dragExit</code> on the
- * <code>DragSourceListener</code>s registered with this
- * <code>DragSourceContext</code> and with the associated
- * <code>DragSource</code>, and passes them the specified
- * <code>DragSourceEvent</code>.
+ * Calls {@code dragExit} on the
+ * {@code DragSourceListener}s registered with this
+ * {@code DragSourceContext} and with the associated
+ * {@code DragSource}, and passes them the specified
+ * {@code DragSourceEvent}.
*
- * @param dse the <code>DragSourceEvent</code>
+ * @param dse the {@code DragSourceEvent}
*/
public void dragExit(DragSourceEvent dse) {
DragSourceListener dsl = listener;
if (dsl != null) {
dsl.dragExit(dse);
@@ -411,17 +411,17 @@
updateCurrentCursor(DnDConstants.ACTION_NONE, DnDConstants.ACTION_NONE, DEFAULT);
}
/**
- * Calls <code>dropActionChanged</code> on the
- * <code>DragSourceListener</code>s registered with this
- * <code>DragSourceContext</code> and with the associated
- * <code>DragSource</code>, and passes them the specified
- * <code>DragSourceDragEvent</code>.
+ * Calls {@code dropActionChanged} on the
+ * {@code DragSourceListener}s registered with this
+ * {@code DragSourceContext} and with the associated
+ * {@code DragSource}, and passes them the specified
+ * {@code DragSourceDragEvent}.
*
- * @param dsde the <code>DragSourceDragEvent</code>
+ * @param dsde the {@code DragSourceDragEvent}
*/
public void dropActionChanged(DragSourceDragEvent dsde) {
DragSourceListener dsl = listener;
if (dsl != null) {
dsl.dropActionChanged(dsde);
@@ -430,45 +430,45 @@
updateCurrentCursor(getSourceActions(), dsde.getTargetActions(), CHANGED);
}
/**
- * Calls <code>dragDropEnd</code> on the
- * <code>DragSourceListener</code>s registered with this
- * <code>DragSourceContext</code> and with the associated
- * <code>DragSource</code>, and passes them the specified
- * <code>DragSourceDropEvent</code>.
+ * Calls {@code dragDropEnd} on the
+ * {@code DragSourceListener}s registered with this
+ * {@code DragSourceContext} and with the associated
+ * {@code DragSource}, and passes them the specified
+ * {@code DragSourceDropEvent}.
*
- * @param dsde the <code>DragSourceDropEvent</code>
+ * @param dsde the {@code DragSourceDropEvent}
*/
public void dragDropEnd(DragSourceDropEvent dsde) {
DragSourceListener dsl = listener;
if (dsl != null) {
dsl.dragDropEnd(dsde);
}
getDragSource().processDragDropEnd(dsde);
}
/**
- * Calls <code>dragMouseMoved</code> on the
- * <code>DragSourceMotionListener</code>s registered with the
- * <code>DragSource</code> associated with this
- * <code>DragSourceContext</code>, and them passes the specified
- * <code>DragSourceDragEvent</code>.
+ * Calls {@code dragMouseMoved} on the
+ * {@code DragSourceMotionListener}s registered with the
+ * {@code DragSource} associated with this
+ * {@code DragSourceContext}, and them passes the specified
+ * {@code DragSourceDragEvent}.
*
- * @param dsde the <code>DragSourceDragEvent</code>
+ * @param dsde the {@code DragSourceDragEvent}
* @since 1.4
*/
public void dragMouseMoved(DragSourceDragEvent dsde) {
getDragSource().processDragMouseMoved(dsde);
}
/**
- * Returns the <code>Transferable</code> associated with
- * this <code>DragSourceContext</code>.
+ * Returns the {@code Transferable} associated with
+ * this {@code DragSourceContext}.
*
- * @return the <code>Transferable</code>
+ * @return the {@code Transferable}
*/
public Transferable getTransferable() { return transferable; }
/**
* If the default drag cursor behavior is active, this method
@@ -476,13 +476,13 @@
* supported by the drag source, the drop target action,
* and status, otherwise this method does nothing.
*
* @param sourceAct the actions supported by the drag source
* @param targetAct the drop target action
- * @param status one of the fields <code>DEFAULT</code>,
- * <code>ENTER</code>, <code>OVER</code>,
- * <code>CHANGED</code>
+ * @param status one of the fields {@code DEFAULT},
+ * {@code ENTER}, {@code OVER},
+ * {@code CHANGED}
*/
@SuppressWarnings("fallthrough")
protected synchronized void updateCurrentCursor(int sourceAct, int targetAct, int status) {
// if the cursor has been previously set then don't do any defaults
@@ -530,25 +530,25 @@
if (peer != null) peer.setCursor(cursor);
}
}
/**
- * Serializes this <code>DragSourceContext</code>. This method first
+ * Serializes this {@code DragSourceContext}. This method first
* performs default serialization. Next, this object's
- * <code>Transferable</code> is written out if and only if it can be
- * serialized. If not, <code>null</code> is written instead. In this case,
- * a <code>DragSourceContext</code> created from the resulting deserialized
- * stream will contain a dummy <code>Transferable</code> which supports no
- * <code>DataFlavor</code>s. Finally, this object's
- * <code>DragSourceListener</code> is written out if and only if it can be
- * serialized. If not, <code>null</code> is written instead.
+ * {@code Transferable} is written out if and only if it can be
+ * serialized. If not, {@code null} is written instead. In this case,
+ * a {@code DragSourceContext} created from the resulting deserialized
+ * stream will contain a dummy {@code Transferable} which supports no
+ * {@code DataFlavor}s. Finally, this object's
+ * {@code DragSourceListener} is written out if and only if it can be
+ * serialized. If not, {@code null} is written instead.
*
* @serialData The default serializable fields, in alphabetical order,
- * followed by either a <code>Transferable</code> instance, or
- * <code>null</code>, followed by either a
- * <code>DragSourceListener</code> instance, or
- * <code>null</code>.
+ * followed by either a {@code Transferable} instance, or
+ * {@code null}, followed by either a
+ * {@code DragSourceListener} instance, or
+ * {@code null}.
* @since 1.4
*/
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
@@ -557,18 +557,18 @@
s.writeObject(SerializationTester.test(listener)
? listener : null);
}
/**
- * Deserializes this <code>DragSourceContext</code>. This method first
- * performs default deserialization for all non-<code>transient</code>
- * fields. This object's <code>Transferable</code> and
- * <code>DragSourceListener</code> are then deserialized as well by using
+ * Deserializes this {@code DragSourceContext}. This method first
+ * performs default deserialization for all non-{@code transient}
+ * fields. This object's {@code Transferable} and
+ * {@code DragSourceListener} are then deserialized as well by using
* the next two objects in the stream. If the resulting
- * <code>Transferable</code> is <code>null</code>, this object's
- * <code>Transferable</code> is set to a dummy <code>Transferable</code>
- * which supports no <code>DataFlavor</code>s.
+ * {@code Transferable} is {@code null}, this object's
+ * {@code Transferable} is set to a dummy {@code Transferable}
+ * which supports no {@code DataFlavor}s.
*
* @since 1.4
*/
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException
@@ -652,21 +652,21 @@
private transient Transferable transferable;
private transient DragSourceListener listener;
/**
- * <code>true</code> if the custom drag cursor is used instead of the
+ * {@code true} if the custom drag cursor is used instead of the
* default one.
*
* @serial
*/
private boolean useCustomCursor;
/**
- * A bitwise mask of <code>DnDConstants</code> that represents the set of
+ * A bitwise mask of {@code DnDConstants} that represents the set of
* drop actions supported by the drag source for the drag operation associated
- * with this <code>DragSourceContext.</code>
+ * with this {@code DragSourceContext.}
*
* @serial
*/
private int sourceActions;
}
< prev index next >