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
 
 
 
 
 
 
 
- 
- All Implemented Interfaces:
 - java.io.Serializable
 
public class MouseWheelEvent extends MouseEventAn event which indicates that the mouse wheel was rotated in a component.A wheel mouse is a mouse which has a wheel in place of the middle button. This wheel can be rotated towards or away from the user. Mouse wheels are most often used for scrolling, though other uses are possible.
A MouseWheelEvent object is passed to every
MouseWheelListenerobject which registered to receive the "interesting" mouse events using the component'saddMouseWheelListenermethod. Each such listener object gets aMouseEventcontaining the mouse event.Due to the mouse wheel's special relationship to scrolling Components, MouseWheelEvents are delivered somewhat differently than other MouseEvents. This is because while other MouseEvents usually affect a change on the Component directly under the mouse cursor (for instance, when clicking a button), MouseWheelEvents often have an effect away from the mouse cursor (moving the wheel while over a Component inside a ScrollPane should scroll one of the Scrollbars on the ScrollPane).
MouseWheelEvents start delivery from the Component underneath the mouse cursor. If MouseWheelEvents are not enabled on the Component, the event is delivered to the first ancestor Container with MouseWheelEvents enabled. This will usually be a ScrollPane with wheel scrolling enabled. The source Component and x,y coordinates will be relative to the event's final destination (the ScrollPane). This allows a complex GUI to be installed without modification into a ScrollPane, and for all MouseWheelEvents to be delivered to the ScrollPane for scrolling.
Some AWT Components are implemented using native widgets which display their own scrollbars and handle their own scrolling. The particular Components for which this is true will vary from platform to platform. When the mouse wheel is moved over one of these Components, the event is delivered straight to the native widget, and not propagated to ancestors.
Platforms offer customization of the amount of scrolling that should take place when the mouse wheel is moved. The two most common settings are to scroll a certain number of "units" (commonly lines of text in a text-based component) or an entire "block" (similar to page-up/page-down). The MouseWheelEvent offers methods for conforming to the underlying platform settings. These platform settings can be changed at any time by the user. MouseWheelEvents reflect the most recent settings.
The
MouseWheelEventclass includes methods for getting the number of "clicks" by which the mouse wheel is rotated. ThegetWheelRotation()method returns the integer number of "clicks" corresponding to the number of notches by which the wheel was rotated. In addition to this method, theMouseWheelEventclass provides thegetPreciseWheelRotation()method which returns a double number of "clicks" in case a partial rotation occurred. ThegetPreciseWheelRotation()method is useful if a mouse supports a high-resolution wheel, such as a freely rotating wheel with no notches. Applications can benefit by using this method to process mouse wheel events more precisely, and thus, making visual perception smoother.- Since:
 - 1.4
 - See Also:
 MouseWheelListener,ScrollPane,ScrollPane.setWheelScrollingEnabled(boolean),JScrollPane,JScrollPane.setWheelScrollingEnabled(boolean), Serialized Form
 
- 
- 
Fields Modifier and Type Field and Description 
ACTION_EVENT_MASK 
The event mask for selecting action events.
ADJUSTMENT_EVENT_MASK 
The event mask for selecting adjustment events.
ALT_DOWN_MASK 
The Alt key extended modifier constant.
ALT_GRAPH_DOWN_MASK 
The AltGraph key extended modifier constant.
ALT_GRAPH_MASK 
The AltGraph key modifier constant.
ALT_MASK 
The Alt key modifier constant.
BUTTON1 
Indicates mouse button #1; used byMouseEvent.getButton().
BUTTON1_DOWN_MASK 
The Mouse Button1 extended modifier constant.
BUTTON1_MASK 
The Mouse Button1 modifier constant.
BUTTON2 
Indicates mouse button #2; used byMouseEvent.getButton().
BUTTON2_DOWN_MASK 
The Mouse Button2 extended modifier constant.
BUTTON2_MASK 
The Mouse Button2 modifier constant.
BUTTON3 
Indicates mouse button #3; used byMouseEvent.getButton().
BUTTON3_DOWN_MASK 
The Mouse Button3 extended modifier constant.
BUTTON3_MASK 
The Mouse Button3 modifier constant.
COMPONENT_EVENT_MASK 
The event mask for selecting component events.
COMPONENT_FIRST 
The first number in the range of ids used for component events.
COMPONENT_HIDDEN 
This event indicates that the component was rendered invisible.
COMPONENT_LAST 
The last number in the range of ids used for component events.
COMPONENT_MOVED 
This event indicates that the component's position changed.
COMPONENT_RESIZED 
This event indicates that the component's size changed.
COMPONENT_SHOWN 
This event indicates that the component was made visible.
consumed 
Controls whether or not the event is sent back down to the peer once the source has processed it - false means it's sent to the peer; true means it's not.
CONTAINER_EVENT_MASK 
The event mask for selecting container events.
CTRL_DOWN_MASK 
The Control key extended modifier constant.
CTRL_MASK 
The Control key modifier constant.
FOCUS_EVENT_MASK 
The event mask for selecting focus events.
HIERARCHY_BOUNDS_EVENT_MASK 
The event mask for selecting hierarchy bounds events.
HIERARCHY_EVENT_MASK 
The event mask for selecting hierarchy events.
id 
The event's id.
INPUT_METHOD_EVENT_MASK 
The event mask for selecting input method events.
INVOCATION_EVENT_MASK 
The event mask for selecting invocation events.
ITEM_EVENT_MASK 
The event mask for selecting item events.
KEY_EVENT_MASK 
The event mask for selecting key events.
META_DOWN_MASK 
The Meta key extended modifier constant.
META_MASK 
The Meta key modifier constant.
MOUSE_CLICKED 
The "mouse clicked" event.
MOUSE_DRAGGED 
The "mouse dragged" event.
MOUSE_ENTERED 
The "mouse entered" event.
MOUSE_EVENT_MASK 
The event mask for selecting mouse events.
MOUSE_EXITED 
The "mouse exited" event.
MOUSE_FIRST 
The first number in the range of ids used for mouse events.
MOUSE_LAST 
The last number in the range of ids used for mouse events.
MOUSE_MOTION_EVENT_MASK 
The event mask for selecting mouse motion events.
MOUSE_MOVED 
The "mouse moved" event.
MOUSE_PRESSED 
The "mouse pressed" event.
MOUSE_RELEASED 
The "mouse released" event.
MOUSE_WHEEL 
The "mouse wheel" event.
MOUSE_WHEEL_EVENT_MASK 
The event mask for selecting mouse wheel events.
NOBUTTON 
Indicates no mouse buttons; used byMouseEvent.getButton().
PAINT_EVENT_MASK 
The event mask for selecting paint events.
RESERVED_ID_MAX 
The maximum value for reserved AWT event IDs.
SHIFT_DOWN_MASK 
The Shift key extended modifier constant.
SHIFT_MASK 
The Shift key modifier constant.
source 
The object on which the Event initially occurred.
TEXT_EVENT_MASK 
The event mask for selecting text events.
WHEEL_BLOCK_SCROLL 
Constant representing scrolling by a "block" (like scrolling with page-up, page-down keys)
WHEEL_UNIT_SCROLL 
Constant representing scrolling by "units" (like scrolling with the arrow keys)
WINDOW_EVENT_MASK 
The event mask for selecting window events.
WINDOW_FOCUS_EVENT_MASK 
The event mask for selecting window focus events.
WINDOW_STATE_EVENT_MASK 
The event mask for selecting window state events. 
- 
Static Methods Modifier and Type Static Method and Description 
getMaskForButton 
A method to obtain a mask for any existing mouse button.
getModifiersExText 
Returns a String describing the extended modifier keys and mouse buttons, such as "Shift", "Button1", or "Ctrl+Shift".
getMouseModifiersText 
Returns aStringinstance describing the modifier keys and mouse buttons that were down during the event, such as "Shift", or "Ctrl+Shift". 
- 
Methods Modifier and Type Method and Description 
consume 
Consumes this event so that it will not be processed in the default manner by the source which originated it.
getButton 
Returns which, if any, of the mouse buttons has changed state.
getClickCount 
Returns the number of mouse clicks associated with this event.
getComponent 
Returns the originator of the event.
getID 
Returns the event type.
getLocationOnScreen 
Returns the absolute x, y position of the event.
getModifiers 
Returns the modifier mask for this event.
getModifiersEx 
Returns the extended modifier mask for this event.
getPoint 
Returns the x,y position of the event relative to the source component.
getPreciseWheelRotation 
Returns the number of "clicks" the mouse wheel was rotated, as a double.
getScrollAmount 
Returns the number of units that should be scrolled per click of mouse wheel rotation.
getScrollType 
Returns the type of scrolling that should take place in response to this event.
getSource 
The object on which the Event initially occurred.
getUnitsToScroll 
This is a convenience method to aid in the implementation of the common-case MouseWheelListener - to scroll a ScrollPane or JScrollPane by an amount which conforms to the platform settings.
getWheelRotation 
Returns the number of "clicks" the mouse wheel was rotated, as an integer.
getWhen 
Returns the difference in milliseconds between the timestamp of when this event occurred and midnight, January 1, 1970 UTC.
getX 
Returns the horizontal x position of the event relative to the source component.
getXOnScreen 
Returns the absolute horizontal x position of the event.
getY 
Returns the vertical y position of the event relative to the source component.
getYOnScreen 
Returns the absolute vertical y position of the event.
isAltDown 
Returns whether or not the Alt modifier is down on this event.
isAltGraphDown 
Returns whether or not the AltGraph modifier is down on this event.
isConsumed 
Returns whether or not this event has been consumed.
isControlDown 
Returns whether or not the Control modifier is down on this event.
isMetaDown 
Returns whether or not the Meta modifier is down on this event.
isPopupTrigger 
Returns whether or not this mouse event is the popup menu trigger event for the platform.
isShiftDown 
Returns whether or not the Shift modifier is down on this event.
paramString 
Returns a parameter string identifying this event.
setSource 
Retargets an event to a new source.
toString 
Returns a String representation of this object.
translatePoint 
Translates the event's coordinates to a new position by adding specifiedx(horizontal) andy(vertical) offsets. 
 - 
 
