GUI Changes: The AWT Grows Up |
Mouse motion events tell you when the user uses the mouse (or a similar input device) to move the onscreen cursor. For information on tracking other mouse event types such as clicks, see Writing a Mouse Listener.Mouse Motion Event Methods
TheMouseMotionListener
interface and its corresponding adapter class,MouseMotionAdapter
, contain two methods:
void mouseDragged(MouseEvent)
- Called by the AWT in response to the user moving the mouse while holding a mouse button down. This event is fired by the component that fired the preceding mouse press event.
void mouseMoved(MouseEvent)
- Called by the AWT in response to the user moving the mouse with no mouse buttons pressed. This event is fired by the listened-to component currently underneath the cursor. [CHECK]
Examples of Handling Mouse Motion Events
The following applet demonstrates mouse motion events. [describe applet][applet goes here]
Try this:
- Do something...
You can find the applet's code [nowhere yet]. Here is the applet's mouse motion event handling code:
[code goes here]You can find more examples of mouse motion listeners in the following sections: [LIST GOES HERE]
The
MouseEvent
ClassEach mouse motion event method has a single parameter -- and it's not calledMouseMotionEvent
! Instead, mouse motion event methods useMouseEvent
objects. See Writing a Mouse Listener for information about theMouseEvent
class.
GUI Changes: The AWT Grows Up |