< prev index next >
src/java.desktop/share/classes/java/awt/event/MouseEvent.java
Print this page
@@ -76,30 +76,30 @@
* <li>the mouse is moved
* <li>the mouse is dragged
* </ul>
* </ul>
* <P>
- * A <code>MouseEvent</code> object is passed to every
- * <code>MouseListener</code>
- * or <code>MouseAdapter</code> object which is registered to receive
+ * A {@code MouseEvent} object is passed to every
+ * {@code MouseListener}
+ * or {@code MouseAdapter} object which is registered to receive
* the "interesting" mouse events using the component's
- * <code>addMouseListener</code> method.
- * (<code>MouseAdapter</code> objects implement the
- * <code>MouseListener</code> interface.) Each such listener object
- * gets a <code>MouseEvent</code> containing the mouse event.
+ * {@code addMouseListener} method.
+ * ({@code MouseAdapter} objects implement the
+ * {@code MouseListener} interface.) Each such listener object
+ * gets a {@code MouseEvent} containing the mouse event.
* <P>
- * A <code>MouseEvent</code> object is also passed to every
- * <code>MouseMotionListener</code> or
- * <code>MouseMotionAdapter</code> object which is registered to receive
+ * A {@code MouseEvent} object is also passed to every
+ * {@code MouseMotionListener} or
+ * {@code MouseMotionAdapter} object which is registered to receive
* mouse motion events using the component's
- * <code>addMouseMotionListener</code>
- * method. (<code>MouseMotionAdapter</code> objects implement the
- * <code>MouseMotionListener</code> interface.) Each such listener object
- * gets a <code>MouseEvent</code> containing the mouse motion event.
+ * {@code addMouseMotionListener}
+ * method. ({@code MouseMotionAdapter} objects implement the
+ * {@code MouseMotionListener} interface.) Each such listener object
+ * gets a {@code MouseEvent} containing the mouse motion event.
* <P>
* When a mouse button is clicked, events are generated and sent to the
- * registered <code>MouseListener</code>s.
+ * registered {@code MouseListener}s.
* The state of modal keys can be retrieved using {@link InputEvent#getModifiers}
* and {@link InputEvent#getModifiersEx}.
* The button mask returned by {@link InputEvent#getModifiers} reflects
* only the button that changed state, not the current state of all buttons.
* (Note: Due to overlap in the values of ALT_MASK/BUTTON2_MASK and
@@ -109,35 +109,35 @@
* {@link InputEvent#getModifiersEx}.
* The button which has changed state is returned by {@link MouseEvent#getButton}
* <P>
* For example, if the first mouse button is pressed, events are sent in the
* following order:
- * <PRE>
- * <b >id </b > <b >modifiers </b > <b >button </b >
- * <code>MOUSE_PRESSED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
- * <code>MOUSE_RELEASED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
- * <code>MOUSE_CLICKED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
- * </PRE>
+ * <pre><b>
+ * id modifiers button</b>{@code
+ * MOUSE_PRESSED: BUTTON1_MASK BUTTON1
+ * MOUSE_RELEASED: BUTTON1_MASK BUTTON1
+ * MOUSE_CLICKED: BUTTON1_MASK BUTTON1
+ * }</pre>
* When multiple mouse buttons are pressed, each press, release, and click
* results in a separate event.
* <P>
* For example, if the user presses <b>button 1</b> followed by
* <b>button 2</b>, and then releases them in the same order,
* the following sequence of events is generated:
- * <PRE>
- * <b >id </b > <b >modifiers </b > <b >button </b >
- * <code>MOUSE_PRESSED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
- * <code>MOUSE_PRESSED</code>: <code>BUTTON2_MASK</code> <code>BUTTON2</code>
- * <code>MOUSE_RELEASED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
- * <code>MOUSE_CLICKED</code>: <code>BUTTON1_MASK</code> <code>BUTTON1</code>
- * <code>MOUSE_RELEASED</code>: <code>BUTTON2_MASK</code> <code>BUTTON2</code>
- * <code>MOUSE_CLICKED</code>: <code>BUTTON2_MASK</code> <code>BUTTON2</code>
- * </PRE>
+ * <pre><b>
+ * id modifiers button</b>{@code
+ * MOUSE_PRESSED: BUTTON1_MASK BUTTON1
+ * MOUSE_PRESSED: BUTTON2_MASK BUTTON2
+ * MOUSE_RELEASED: BUTTON1_MASK BUTTON1
+ * MOUSE_CLICKED: BUTTON1_MASK BUTTON1
+ * MOUSE_RELEASED: BUTTON2_MASK BUTTON2
+ * MOUSE_CLICKED: BUTTON2_MASK BUTTON2
+ * }</pre>
* If <b>button 2</b> is released first, the
- * <code>MOUSE_RELEASED</code>/<code>MOUSE_CLICKED</code> pair
- * for <code>BUTTON2_MASK</code> arrives first,
- * followed by the pair for <code>BUTTON1_MASK</code>.
+ * {@code MOUSE_RELEASED}/{@code MOUSE_CLICKED} pair
+ * for {@code BUTTON2_MASK} arrives first,
+ * followed by the pair for {@code BUTTON1_MASK}.
* <p>
* Some extra mouse buttons are added to extend the standard set of buttons
* represented by the following constants:{@code BUTTON1}, {@code BUTTON2}, and {@code BUTTON3}.
* Extra buttons have no assigned {@code BUTTONx}
* constants as well as their button masks have no assigned {@code BUTTONx_DOWN_MASK}
@@ -152,24 +152,24 @@
* {@code Component}). Due to platform-dependent Drag&Drop implementations,
* {@code MOUSE_DRAGGED} events may not be delivered during a native
* Drag&Drop operation.
*
* In a multi-screen environment mouse drag events are delivered to the
- * <code>Component</code> even if the mouse position is outside the bounds of the
- * <code>GraphicsConfiguration</code> associated with that
- * <code>Component</code>. However, the reported position for mouse drag events
+ * {@code Component} even if the mouse position is outside the bounds of the
+ * {@code GraphicsConfiguration} associated with that
+ * {@code Component}. However, the reported position for mouse drag events
* in this case may differ from the actual mouse position:
* <ul>
* <li>In a multi-screen environment without a virtual device:
* <br>
* The reported coordinates for mouse drag events are clipped to fit within the
- * bounds of the <code>GraphicsConfiguration</code> associated with
- * the <code>Component</code>.
+ * bounds of the {@code GraphicsConfiguration} associated with
+ * the {@code Component}.
* <li>In a multi-screen environment with a virtual device:
* <br>
* The reported coordinates for mouse drag events are clipped to fit within the
- * bounds of the virtual device associated with the <code>Component</code>.
+ * bounds of the virtual device associated with the {@code Component}.
* </ul>
* <p>
* An unspecified behavior will be caused if the {@code id} parameter
* of any particular {@code MouseEvent} instance is not
* in the range from {@code MOUSE_FIRST} to {@code MOUSE_LAST}-1
@@ -198,55 +198,55 @@
* The last number in the range of ids used for mouse events.
*/
public static final int MOUSE_LAST = 507;
/**
- * The "mouse clicked" event. This <code>MouseEvent</code>
+ * The "mouse clicked" event. This {@code MouseEvent}
* occurs when a mouse button is pressed and released.
*/
public static final int MOUSE_CLICKED = MOUSE_FIRST;
/**
- * The "mouse pressed" event. This <code>MouseEvent</code>
+ * The "mouse pressed" event. This {@code MouseEvent}
* occurs when a mouse button is pushed down.
*/
public static final int MOUSE_PRESSED = 1 + MOUSE_FIRST; //Event.MOUSE_DOWN
/**
- * The "mouse released" event. This <code>MouseEvent</code>
+ * The "mouse released" event. This {@code MouseEvent}
* occurs when a mouse button is let up.
*/
public static final int MOUSE_RELEASED = 2 + MOUSE_FIRST; //Event.MOUSE_UP
/**
- * The "mouse moved" event. This <code>MouseEvent</code>
+ * The "mouse moved" event. This {@code MouseEvent}
* occurs when the mouse position changes.
*/
public static final int MOUSE_MOVED = 3 + MOUSE_FIRST; //Event.MOUSE_MOVE
/**
- * The "mouse entered" event. This <code>MouseEvent</code>
+ * The "mouse entered" event. This {@code MouseEvent}
* occurs when the mouse cursor enters the unobscured part of component's
* geometry.
*/
public static final int MOUSE_ENTERED = 4 + MOUSE_FIRST; //Event.MOUSE_ENTER
/**
- * The "mouse exited" event. This <code>MouseEvent</code>
+ * The "mouse exited" event. This {@code MouseEvent}
* occurs when the mouse cursor exits the unobscured part of component's
* geometry.
*/
public static final int MOUSE_EXITED = 5 + MOUSE_FIRST; //Event.MOUSE_EXIT
/**
- * The "mouse dragged" event. This <code>MouseEvent</code>
+ * The "mouse dragged" event. This {@code MouseEvent}
* occurs when the mouse position changes while a mouse button is pressed.
*/
public static final int MOUSE_DRAGGED = 6 + MOUSE_FIRST; //Event.MOUSE_DRAG
/**
- * The "mouse wheel" event. This is the only <code>MouseWheelEvent</code>.
+ * The "mouse wheel" event. This is the only {@code MouseWheelEvent}.
* It occurs when a mouse equipped with a wheel has its wheel rotated.
* @since 1.4
*/
public static final int MOUSE_WHEEL = 7 + MOUSE_FIRST;
@@ -318,14 +318,14 @@
/**
* Indicates the number of quick consecutive clicks of
* a mouse button.
* clickCount will be valid for only three mouse events :<BR>
- * <code>MOUSE_CLICKED</code>,
- * <code>MOUSE_PRESSED</code> and
- * <code>MOUSE_RELEASED</code>.
- * For the above, the <code>clickCount</code> will be at least 1.
+ * {@code MOUSE_CLICKED},
+ * {@code MOUSE_PRESSED} and
+ * {@code MOUSE_RELEASED}.
+ * For the above, the {@code clickCount} will be at least 1.
* For all other events the count will be 0.
*
* @serial
* @see #getClickCount()
*/
@@ -363,12 +363,12 @@
int button;
/**
* A property used to indicate whether a Popup Menu
* should appear with a certain gestures.
- * If <code>popupTrigger</code> = <code>false</code>,
- * no popup menu should appear. If it is <code>true</code>
+ * If {@code popupTrigger} = {@code false},
+ * no popup menu should appear. If it is {@code true}
* then a popup menu should appear.
*
* @serial
* @see java.awt.PopupMenu
* @see #isPopupTrigger()
@@ -413,11 +413,11 @@
* desktop area could span multiple physical screen devices,
* these coordinates are relative to the virtual coordinate system.
* Otherwise, these coordinates are relative to the coordinate system
* associated with the Component's GraphicsConfiguration.
*
- * @return a <code>Point</code> object containing the absolute x
+ * @return a {@code Point} object containing the absolute x
* and y coordinates.
*
* @see java.awt.GraphicsConfiguration
* @since 1.6
*/
@@ -458,32 +458,32 @@
public int getYOnScreen() {
return yAbs;
}
/**
- * Constructs a <code>MouseEvent</code> object with the
+ * Constructs a {@code MouseEvent} object with the
* specified source component,
* type, time, modifiers, coordinates, click count, popupTrigger flag,
* and button number.
* <p>
* Creating an invalid event (such
* as by using more than one of the old _MASKs, or modifier/button
* values which don't match) results in unspecified behavior.
* An invocation of the form
- * <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger, button)</tt>
+ * {@code MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger, button)}
* behaves in exactly the same way as the invocation
- * <tt> {@link #MouseEvent(Component, int, long, int, int, int,
- * int, int, int, boolean, int) MouseEvent}(source, id, when, modifiers,
- * x, y, xAbs, yAbs, clickCount, popupTrigger, button)</tt>
+ * {@link #MouseEvent(Component, int, long, int, int, int,
+ * int, int, int, boolean, int) MouseEvent(source, id, when, modifiers,
+ * x, y, xAbs, yAbs, clickCount, popupTrigger, button)}
* where xAbs and yAbs defines as source's location on screen plus
* relative coordinates x and y.
* xAbs and yAbs are set to zero if the source is not showing.
* This method throws an
- * <code>IllegalArgumentException</code> if <code>source</code>
- * is <code>null</code>.
+ * {@code IllegalArgumentException} if {@code source}
+ * is {@code null}.
*
- * @param source The <code>Component</code> that originated the event
+ * @param source The {@code Component} that originated the event
* @param id An integer indicating the type of event.
* For information on allowable values, see
* the class description for {@link MouseEvent}
* @param when A long integer that gives the time the event occurred.
* Passing negative or zero value
@@ -525,20 +525,20 @@
* using buttons from the range starting from 4 to
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* if the mouse has more than three buttons.
* </ul>
* @throws IllegalArgumentException if {@code button} is less then zero
- * @throws IllegalArgumentException if <code>source</code> is null
+ * @throws IllegalArgumentException if {@code source} is null
* @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if {@code button} is greater then the
* {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
* for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
* by Java
- * @throws IllegalArgumentException if an invalid <code>button</code>
+ * @throws IllegalArgumentException if an invalid {@code button}
* value is passed in
- * @throws IllegalArgumentException if <code>source</code> is null
+ * @throws IllegalArgumentException if {@code source} is null
* @see #getSource()
* @see #getID()
* @see #getWhen()
* @see #getModifiers()
* @see #getX()
@@ -563,26 +563,26 @@
this.yAbs = 0;
}
}
/**
- * Constructs a <code>MouseEvent</code> object with the
+ * Constructs a {@code MouseEvent} object with the
* specified source component,
* type, modifiers, coordinates, click count, and popupTrigger flag.
* An invocation of the form
- * <tt>MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger)</tt>
+ * {@code MouseEvent(source, id, when, modifiers, x, y, clickCount, popupTrigger)}
* behaves in exactly the same way as the invocation
- * <tt> {@link #MouseEvent(Component, int, long, int, int, int,
- * int, int, int, boolean, int) MouseEvent}(source, id, when, modifiers,
- * x, y, xAbs, yAbs, clickCount, popupTrigger, MouseEvent.NOBUTTON)</tt>
+ * {@link #MouseEvent(Component, int, long, int, int, int,
+ * int, int, int, boolean, int) MouseEvent(source, id, when, modifiers,
+ * x, y, xAbs, yAbs, clickCount, popupTrigger, MouseEvent.NOBUTTON)}
* where xAbs and yAbs defines as source's location on screen plus
* relative coordinates x and y.
* xAbs and yAbs are set to zero if the source is not showing.
- * This method throws an <code>IllegalArgumentException</code>
- * if <code>source</code> is <code>null</code>.
+ * This method throws an {@code IllegalArgumentException}
+ * if {@code source} is {@code null}.
*
- * @param source The <code>Component</code> that originated the event
+ * @param source The {@code Component} that originated the event
* @param id An integer indicating the type of event.
* For information on allowable values, see
* the class description for {@link MouseEvent}
* @param when A long integer that gives the time the event occurred.
* Passing negative or zero value
@@ -603,11 +603,11 @@
* @param clickCount The number of mouse clicks associated with event.
* Passing negative value
* is not recommended
* @param popupTrigger A boolean that equals {@code true} if this event
* is a trigger for a popup menu
- * @throws IllegalArgumentException if <code>source</code> is null
+ * @throws IllegalArgumentException if {@code source} is null
* @see #getSource()
* @see #getID()
* @see #getWhen()
* @see #getModifiers()
* @see #getX()
@@ -635,11 +635,11 @@
}
return tmpModifiers & ~JDK_1_3_MODIFIERS;
}
/**
- * Constructs a <code>MouseEvent</code> object with the
+ * Constructs a {@code MouseEvent} object with the
* specified source component,
* type, time, modifiers, coordinates, absolute coordinates, click count, popupTrigger flag,
* and button number.
* <p>
* Creating an invalid event (such
@@ -647,14 +647,14 @@
* values which don't match) results in unspecified behavior.
* Even if inconsistent values for relative and absolute coordinates are
* passed to the constructor, the mouse event instance is still
* created and no exception is thrown.
* This method throws an
- * <code>IllegalArgumentException</code> if <code>source</code>
- * is <code>null</code>.
+ * {@code IllegalArgumentException} if {@code source}
+ * is {@code null}.
*
- * @param source The <code>Component</code> that originated the event
+ * @param source The {@code Component} that originated the event
* @param id An integer indicating the type of event.
* For information on allowable values, see
* the class description for {@link MouseEvent}
* @param when A long integer that gives the time the event occurred.
* Passing negative or zero value
@@ -700,20 +700,20 @@
* using buttons from the range starting from 4 to
* {@link java.awt.MouseInfo#getNumberOfButtons() MouseInfo.getNumberOfButtons()}
* if the mouse has more than three buttons.
* </ul>
* @throws IllegalArgumentException if {@code button} is less then zero
- * @throws IllegalArgumentException if <code>source</code> is null
+ * @throws IllegalArgumentException if {@code source} is null
* @throws IllegalArgumentException if {@code button} is greater then BUTTON3 and the support for extended mouse buttons is
* {@link Toolkit#areExtraMouseButtonsEnabled() disabled} by Java
* @throws IllegalArgumentException if {@code button} is greater then the
* {@link java.awt.MouseInfo#getNumberOfButtons() current number of buttons} and the support
* for extended mouse buttons is {@link Toolkit#areExtraMouseButtonsEnabled() enabled}
* by Java
- * @throws IllegalArgumentException if an invalid <code>button</code>
+ * @throws IllegalArgumentException if an invalid {@code button}
* value is passed in
- * @throws IllegalArgumentException if <code>source</code> is null
+ * @throws IllegalArgumentException if {@code source} is null
* @see #getSource()
* @see #getID()
* @see #getWhen()
* @see #getModifiers()
* @see #getX()
@@ -801,11 +801,11 @@
}
/**
* Returns the x,y position of the event relative to the source component.
*
- * @return a <code>Point</code> object containing the x and y coordinates
+ * @return a {@code Point} object containing the x and y coordinates
* relative to the source component
*
*/
public Point getPoint() {
int x;
@@ -817,11 +817,11 @@
return new Point(x, y);
}
/**
* Translates the event's coordinates to a new position
- * by adding specified <code>x</code> (horizontal) and <code>y</code>
+ * by adding specified {@code x} (horizontal) and {@code y}
* (vertical) offsets.
*
* @param x the horizontal x value to add to the current x
* coordinate position
* @param y the vertical y value to add to the current y
@@ -899,33 +899,33 @@
/**
* Returns whether or not this mouse event is the popup menu
* trigger event for the platform.
* <p><b>Note</b>: Popup menus are triggered differently
- * on different systems. Therefore, <code>isPopupTrigger</code>
- * should be checked in both <code>mousePressed</code>
- * and <code>mouseReleased</code>
+ * on different systems. Therefore, {@code isPopupTrigger}
+ * should be checked in both {@code mousePressed}
+ * and {@code mouseReleased}
* for proper cross-platform functionality.
*
* @return boolean, true if this event is the popup menu trigger
* for this platform
*/
public boolean isPopupTrigger() {
return popupTrigger;
}
/**
- * Returns a <code>String</code> instance describing the modifier keys and
+ * Returns a {@code String} instance describing the modifier keys and
* mouse buttons that were down during the event, such as "Shift",
* or "Ctrl+Shift". These strings can be localized by changing
- * the <code>awt.properties</code> file.
+ * the {@code awt.properties} file.
* <p>
- * Note that the <code>InputEvent.ALT_MASK</code> and
- * <code>InputEvent.BUTTON2_MASK</code> have equal values,
+ * Note that the {@code InputEvent.ALT_MASK} and
+ * {@code InputEvent.BUTTON2_MASK} have equal values,
* so the "Alt" string is returned for both modifiers. Likewise,
- * the <code>InputEvent.META_MASK</code> and
- * <code>InputEvent.BUTTON3_MASK</code> have equal values,
+ * the {@code InputEvent.META_MASK} and
+ * {@code InputEvent.BUTTON3_MASK} have equal values,
* so the "Meta" string is returned for both modifiers.
* <p>
* Note that passing negative parameter is incorrect,
* and will cause the returning an unspecified string.
* Zero parameter means that no modifiers were passed and will
< prev index next >