Monday, 24 February 2014

EVENT CLASSES:MouseWheelEvent class

The MouseWheelEvent class encapsulates a mouse wheel event.........

The MouseWheelEvent Class:

        
The MouseWheelEvent class encapsulates a mouse wheel event. It is a subclass of MouseEvent. Not all mice have wheels. If a mouse has a wheel, it is located between the left and right buttons. Mouse wheels are used for  scrolling.

MouseWheelEvent :- integer constants:

  • WHEEL_BLOCK_SCROLL :      A page-up or page-down scroll event occurred.
  • WHEEL_UNIT_SCROLL      :          A line-up or line-down scroll event occurred.


MouseWheelEvent:-constructor


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

             Here,src is a reference to the object that generated the event. The type of the event is specified by type. The system time at which the mouse event occurred is passed in when. The modifiers argument indicates which modifiers were pressed when the event occurred. The coordinates of the mouse are passed in x and y. The number of clicks the wheel has rotated is passed in clicks. The triggersPopup flag indicates if this event causes a pop-up menu to appear on this  platform. The scrollHow value must be either WHEEL_UNIT_SCROLL or WHEEL_BLOCK_SCROLL. The number of units to scroll is passed in amount. The count parameter indicates the number of rotational units that the wheel moved.

MouseWheelEvent :-Methods

           
           MouseWheelEvent defines methods that give you access to the wheel event.
  • getWheelRotation() method : To obtain the number of rotational units, call getWheelRotation().It returns the number of rotational units. If the value is positive, the wheel moved counterclockwise. If the value is negative, the wheel moved clockwise.

          syntax:
            int getWheelRotation( )

  • getScrollType() method:To obtain the type of scroll, call getScrollType( ).It returns either WHEEL_UNIT_SCROLL or WHEEL_BLOCK_SCROLL.

            syntax:
                   int getScrollType()

  • getScrollAmount() method:  If the scroll type isWHEEL_UNIT_SCROLL, you can obtain the number of units to scroll by calling getScrollAmount( ).

         syntax:
                  int getScrollAmount( )

No comments:

Post a Comment