Methods for Mouse Events
All mouse events report the x and y location of the mouse in pixels:
- event.getX ( ) ;
- event.getY ( ) ;
You can also obtain the click count for double or event triple clicks:
- event.getClickCount ( ) ;
You can distinguish between different mouse buttons:
- ( event.getModifiers ( ) & InputEvent.BUTTON3_MASK ) != 0tests for a right click of the mouse
Note that one response to mouse motion can be to change the appearance of the cursor. There are 14 different built-in cursors as well as a Toolkit method to define your own.
- if ( b ) setCursor ( Cursor.getDefaultCursor ( ) ) else setCursor ( Cursor.getPredefinedCursor ( Cursor.HAND_CURSOR ));