Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt.event

Class MouseWheelEvent

java.lang.Object
|
+--java.util.EventObject
   |
   +--java.awt.AWTEvent
      |
      +--java.awt.event.ComponentEvent
         |
         +--java.awt.event.InputEvent
            |
            +--java.awt.event.MouseEvent
               |
               +--java.awt.event.MouseWheelEvent


public class MouseWheelEvent

extends MouseEvent

This event is generated for a mouse wheel rotation. The wheel (the middle mouse button on most modern mice) can be rotated towards or away from the user, and is ofteh used for scrolling.

Because of the special use for scrolling components, MouseWheelEvents often affect a different component than the one located at the point of the event. If the component under the mouse cursor does not accept wheel events, the event is passed to the first ancestor container which does. This is often a ScrollPane, which knows how to scroll. If an AWT component is built from a native widget that knows how to use mouse wheel events, that component will consume the event.

The two most common scroll types are "units" (lines at a time) or "blocks" (pages at a time). The initial setting is taken from the platform, although the user can adjust the setting at any time.

Since:Author:See Also:

Field Summary

static intWHEEL_BLOCK_SCROLL

Indicates scrolling by blocks (pages).
static intWHEEL_UNIT_SCROLL

Indicates scrolling by units (lines).

Constructor Summary

MouseWheelEvent(java.awt.Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger, int scrollType, int scrollAmount, int wheelRotation)

Initializes a new instance of MouseWheelEvent with the specified information.

Method Summary

intgetScrollAmount()

Returns the number of units to scroll in response to this event.
intgetScrollType()

This method returns the scrolling pattern this event requests.
intgetUnitsToScroll()

This is a convenience method which aids in a common listener for scrolling a scrollpane (although this is already built into ScrollPane and JScrollPane).
intgetWheelRotation()

Gets the number of "clicks" the wheel was rotated.
java.lang.StringparamString()

Returns a string identifying this event.

Field Details

WHEEL_BLOCK_SCROLL

public static final int WHEEL_BLOCK_SCROLL

Indicates scrolling by blocks (pages).

See Also:


WHEEL_UNIT_SCROLL

public static final int WHEEL_UNIT_SCROLL

Indicates scrolling by units (lines).

See Also:


Constructor Details

MouseWheelEvent

public MouseWheelEvent(java.awt.Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger, int scrollType, int scrollAmount, int wheelRotation)

Initializes a new instance of MouseWheelEvent with the specified information. Note that an invalid id leads to unspecified results. #WHEEL_BLOCK_SCROLL

Parameters:

Throws:

See Also:


Method Details

getScrollAmount

public int getScrollAmount()

Returns the number of units to scroll in response to this event. This only makes sense when the scroll type is WHEEL_UNIT_SCROLL.

Returns:

See Also:


getScrollType

public int getScrollType()

This method returns the scrolling pattern this event requests. Legal values are WHEEL_UNIT_SCROLL and WHEEL_BLOCK_SCROLL.

Returns:

See Also:


getUnitsToScroll

public int getUnitsToScroll()

This is a convenience method which aids in a common listener for scrolling a scrollpane (although this is already built into ScrollPane and JScrollPane). This method only makes sense when getScrollType() returns WHEEL_UNIT_SCROLL.

This accounts for direction of scroll and amount of wheel movement, as interpreted by the platform settings.

Returns:

See Also:


getWheelRotation

public int getWheelRotation()

Gets the number of "clicks" the wheel was rotated. Negative values move up (away) from the user, positive values move down (towards) the user.

Returns:


paramString

public String paramString()

Returns a string identifying this event. For mouse wheel events, this is super.paramString() + ",scrollType=WHEEL_" + (getScrollType() == WHEEL_UNIT_SCROLL ? "UNIT" : "BLOCK") + "_SCROLL,scrollAmount=" + getScrollAmount() + ",wheelRotation=" + getWheelRotation().

Returns: