java.awt.event

Class MouseWheelEvent

  • All Implemented Interfaces:
    java.io.Serializable
    public class MouseWheelEvent extends MouseEvent
    An 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 MouseWheelListener object which registered to receive the "interesting" mouse events using the component's addMouseWheelListener method. Each such listener object gets a MouseEvent containing 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 MouseWheelEvent class includes methods for getting the number of "clicks" by which the mouse wheel is rotated. The getWheelRotation() method returns the integer number of "clicks" corresponding to the number of notches by which the wheel was rotated. In addition to this method, the MouseWheelEvent class provides the getPreciseWheelRotation() method which returns a double number of "clicks" in case a partial rotation occurred. The getPreciseWheelRotation() 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
      Inherited member indicator ACTION_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting action events.
      Inherited member indicator ADJUSTMENT_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting adjustment events.
      Inherited member indicator ALT_DOWN_MASK Reveal DetailHide Detail
      The Alt key extended modifier constant.
      Inherited member indicator ALT_GRAPH_DOWN_MASK Reveal DetailHide Detail
      The AltGraph key extended modifier constant.
      Inherited member indicator ALT_GRAPH_MASK Reveal DetailHide Detail
      The AltGraph key modifier constant.
      Inherited member indicator ALT_MASK Reveal DetailHide Detail
      The Alt key modifier constant.
      Inherited member indicator BUTTON1 Reveal DetailHide Detail
      Indicates mouse button #1; used by MouseEvent.getButton().
      Inherited member indicator BUTTON1_DOWN_MASK Reveal DetailHide Detail
      The Mouse Button1 extended modifier constant.
      Inherited member indicator BUTTON1_MASK Reveal DetailHide Detail
      The Mouse Button1 modifier constant.
      Inherited member indicator BUTTON2 Reveal DetailHide Detail
      Indicates mouse button #2; used by MouseEvent.getButton().
      Inherited member indicator BUTTON2_DOWN_MASK Reveal DetailHide Detail
      The Mouse Button2 extended modifier constant.
      Inherited member indicator BUTTON2_MASK Reveal DetailHide Detail
      The Mouse Button2 modifier constant.
      Inherited member indicator BUTTON3 Reveal DetailHide Detail
      Indicates mouse button #3; used by MouseEvent.getButton().
      Inherited member indicator BUTTON3_DOWN_MASK Reveal DetailHide Detail
      The Mouse Button3 extended modifier constant.
      Inherited member indicator BUTTON3_MASK Reveal DetailHide Detail
      The Mouse Button3 modifier constant.
      Inherited member indicator COMPONENT_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting component events.
      Inherited member indicator COMPONENT_FIRST Reveal DetailHide Detail
      The first number in the range of ids used for component events.
      Inherited member indicator COMPONENT_HIDDEN Reveal DetailHide Detail
      This event indicates that the component was rendered invisible.
      Inherited member indicator COMPONENT_LAST Reveal DetailHide Detail
      The last number in the range of ids used for component events.
      Inherited member indicator COMPONENT_MOVED Reveal DetailHide Detail
      This event indicates that the component's position changed.
      Inherited member indicator COMPONENT_RESIZED Reveal DetailHide Detail
      This event indicates that the component's size changed.
      Inherited member indicator COMPONENT_SHOWN Reveal DetailHide Detail
      This event indicates that the component was made visible.
      Inherited member indicator CONTAINER_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting container events.
      Inherited member indicator CTRL_DOWN_MASK Reveal DetailHide Detail
      The Control key extended modifier constant.
      Inherited member indicator CTRL_MASK Reveal DetailHide Detail
      The Control key modifier constant.
      Inherited member indicator FOCUS_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting focus events.
      Inherited member indicator HIERARCHY_BOUNDS_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting hierarchy bounds events.
      Inherited member indicator HIERARCHY_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting hierarchy events.
      Inherited member indicator INPUT_METHOD_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting input method events.
      Inherited member indicator INVOCATION_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting invocation events.
      Inherited member indicator ITEM_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting item events.
      Inherited member indicator KEY_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting key events.
      Inherited member indicator META_DOWN_MASK Reveal DetailHide Detail
      The Meta key extended modifier constant.
      Inherited member indicator META_MASK Reveal DetailHide Detail
      The Meta key modifier constant.
      Inherited member indicator MOUSE_CLICKED Reveal DetailHide Detail
      The "mouse clicked" event.
      Inherited member indicator MOUSE_DRAGGED Reveal DetailHide Detail
      The "mouse dragged" event.
      Inherited member indicator MOUSE_ENTERED Reveal DetailHide Detail
      The "mouse entered" event.
      Inherited member indicator MOUSE_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting mouse events.
      Inherited member indicator MOUSE_EXITED Reveal DetailHide Detail
      The "mouse exited" event.
      Inherited member indicator MOUSE_FIRST Reveal DetailHide Detail
      The first number in the range of ids used for mouse events.
      Inherited member indicator MOUSE_LAST Reveal DetailHide Detail
      The last number in the range of ids used for mouse events.
      Inherited member indicator MOUSE_MOTION_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting mouse motion events.
      Inherited member indicator MOUSE_MOVED Reveal DetailHide Detail
      The "mouse moved" event.
      Inherited member indicator MOUSE_PRESSED Reveal DetailHide Detail
      The "mouse pressed" event.
      Inherited member indicator MOUSE_RELEASED Reveal DetailHide Detail
      The "mouse released" event.
      Inherited member indicator MOUSE_WHEEL Reveal DetailHide Detail
      The "mouse wheel" event.
      Inherited member indicator MOUSE_WHEEL_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting mouse wheel events.
      Inherited member indicator NOBUTTON Reveal DetailHide Detail
      Indicates no mouse buttons; used by MouseEvent.getButton().
      Inherited member indicator PAINT_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting paint events.
      Inherited member indicator RESERVED_ID_MAX Reveal DetailHide Detail
      The maximum value for reserved AWT event IDs.
      Inherited member indicator SHIFT_DOWN_MASK Reveal DetailHide Detail
      The Shift key extended modifier constant.
      Inherited member indicator SHIFT_MASK Reveal DetailHide Detail
      The Shift key modifier constant.
      Inherited member indicator TEXT_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting text events.
      Ordinary member indicator WHEEL_BLOCK_SCROLL Reveal DetailHide Detail
      Constant representing scrolling by a "block" (like scrolling with page-up, page-down keys)
      Ordinary member indicator WHEEL_UNIT_SCROLL Reveal DetailHide Detail
      Constant representing scrolling by "units" (like scrolling with the arrow keys)
      Inherited member indicator WINDOW_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting window events.
      Inherited member indicator WINDOW_FOCUS_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting window focus events.
      Inherited member indicator WINDOW_STATE_EVENT_MASK Reveal DetailHide Detail
      The event mask for selecting window state events.
    • Static Methods 
      Modifier and Type Static Method and Description
      Inherited member indicator getMaskForButton Reveal DetailHide Detail
      A method to obtain a mask for any existing mouse button.
      Inherited member indicator getModifiersExText Reveal DetailHide Detail
      Returns a String describing the extended modifier keys and mouse buttons, such as "Shift", "Button1", or "Ctrl+Shift".
      Inherited member indicator getMouseModifiersText Reveal DetailHide Detail
      Returns a String instance describing the modifier keys and mouse buttons that were down during the event, such as "Shift", or "Ctrl+Shift".
    • Constructors 
      Constructor and Description
      Ordinary member indicator MouseWheelEvent Reveal DetailHide Detail
      Constructs a MouseWheelEvent object with the specified source component, type, modifiers, coordinates, scroll type, scroll amount, and wheel rotation.
      Ordinary member indicator MouseWheelEvent Reveal DetailHide Detail
      Constructs a MouseWheelEvent object with the specified source component, type, modifiers, coordinates, absolute coordinates, scroll type, scroll amount, and wheel rotation.
      Ordinary member indicator MouseWheelEvent Reveal DetailHide Detail
      Constructs a MouseWheelEvent object with the specified source component, type, modifiers, coordinates, absolute coordinates, scroll type, scroll amount, and wheel rotation.
    • Methods 
      Modifier and Type Method and Description
      Inherited member indicator consume Reveal DetailHide Detail
      Consumes this event so that it will not be processed in the default manner by the source which originated it.
      Inherited member indicator getButton Reveal DetailHide Detail
      Returns which, if any, of the mouse buttons has changed state.
      Inherited member indicator getClickCount Reveal DetailHide Detail
      Returns the number of mouse clicks associated with this event.
      Inherited member indicator getComponent Reveal DetailHide Detail
      Returns the originator of the event.
      Inherited member indicator getID Reveal DetailHide Detail
      Returns the event type.
      Inherited member indicator getLocationOnScreen Reveal DetailHide Detail
      Returns the absolute x, y position of the event.
      Inherited member indicator getModifiers Reveal DetailHide Detail
      Returns the modifier mask for this event.
      Inherited member indicator getModifiersEx Reveal DetailHide Detail
      Returns the extended modifier mask for this event.
      Inherited member indicator getPoint Reveal DetailHide Detail
      Returns the x,y position of the event relative to the source component.
      Ordinary member indicator getPreciseWheelRotation Reveal DetailHide Detail
      Returns the number of "clicks" the mouse wheel was rotated, as a double.
      Ordinary member indicator getScrollAmount Reveal DetailHide Detail
      Returns the number of units that should be scrolled per click of mouse wheel rotation.
      Ordinary member indicator getScrollType Reveal DetailHide Detail
      Returns the type of scrolling that should take place in response to this event.
      Inherited member indicator getSource Reveal DetailHide Detail
      The object on which the Event initially occurred.
      Ordinary member indicator getUnitsToScroll Reveal DetailHide Detail
      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.
      Ordinary member indicator getWheelRotation Reveal DetailHide Detail
      Returns the number of "clicks" the mouse wheel was rotated, as an integer.
      Inherited member indicator getWhen Reveal DetailHide Detail
      Returns the difference in milliseconds between the timestamp of when this event occurred and midnight, January 1, 1970 UTC.
      Inherited member indicator getX Reveal DetailHide Detail
      Returns the horizontal x position of the event relative to the source component.
      Inherited member indicator getXOnScreen Reveal DetailHide Detail
      Returns the absolute horizontal x position of the event.
      Inherited member indicator getY Reveal DetailHide Detail
      Returns the vertical y position of the event relative to the source component.
      Inherited member indicator getYOnScreen Reveal DetailHide Detail
      Returns the absolute vertical y position of the event.
      Inherited member indicator isAltDown Reveal DetailHide Detail
      Returns whether or not the Alt modifier is down on this event.
      Inherited member indicator isAltGraphDown Reveal DetailHide Detail
      Returns whether or not the AltGraph modifier is down on this event.
      Inherited member indicator isConsumed Reveal DetailHide Detail
      Returns whether or not this event has been consumed.
      Inherited member indicator isControlDown Reveal DetailHide Detail
      Returns whether or not the Control modifier is down on this event.
      Inherited member indicator isMetaDown Reveal DetailHide Detail
      Returns whether or not the Meta modifier is down on this event.
      Inherited member indicator isPopupTrigger Reveal DetailHide Detail
      Returns whether or not this mouse event is the popup menu trigger event for the platform.
      Inherited member indicator isShiftDown Reveal DetailHide Detail
      Returns whether or not the Shift modifier is down on this event.
      Overridden member indicator paramString Reveal DetailHide Detail
      Returns a parameter string identifying this event.
      Inherited member indicator setSource Reveal DetailHide Detail
      Retargets an event to a new source.
      Inherited member indicator toString Reveal DetailHide Detail
      Returns a String representation of this object.
      Inherited member indicator translatePoint Reveal DetailHide Detail
      Translates the event's coordinates to a new position by adding specified x (horizontal) and y (vertical) offsets.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
This document was created by Dulcet from the OpenJDK sources. Copyright © 1993, 2012 Oracle and/or its affiliates. All rights reserved.

SourceForge