MouseWheelEvent class in java.awt.event package: Integer constants, Constructor, Methods

MouseWheelEvent class in java.awt.event package handles events created when mouse wheel is moved. It is a subclass of MouseEvent class.

Integer constants defined by MouseWheelEvent class:

  • WHEEL_UNIT_SCROLL: For a line up or line down scroll event.
  • WHEEL_BLOCK_SCROLL: For a page up or page down scroll event.

Constructor defined by MouseWheelEvent class:

By using source, type of event, when event was created, modifiers, coordinates of mouse, click count, triggersp to show if the event results in a popup menu, scrhow value is either WHEEL_UNIT_SCROLL or WHEEL_BLOCK_SCROLL, n is number of units to scroll and count is for number of rotations of the mouse wheel.

MouseWheelEvent(Component src, int type, long when, int modifiers, int x, int y, int clicks, boolean triggersPopup, int scrhow, int n, int count)

Methods defined by MouseWheelEvent class:

getWheelRotation( ) method: It is used to get the number of rotations of mouse wheel. For a positive value, wheel moved counterclockwise and for a negative value it moved clockwise.


int getWheelRotation( )

getScrollType( ) method: It is used to return the type of scroll. Its value could be either WHEEL_UNIT_SCROLL or WHEEL_BLOCK_SCROLL.


int getScrollType( )

getScrollAmount( ) method: It is used to get number of units to scroll, provided the scroll type is WHEEL_UNIT_SCROLL.


int getScrollAmount( )

Leave a Reply