Previous | Next | Trail Map | To 1.1 -- And Beyond! | GUI Changes: The AWT Grows Up


Writing a Mouse Motion Listener

Mouse motion events tell you when the user moves the onscreen cursor using the mouse or a similar input device. For information on tracking other mouse event types such as clicks, see Writing a Mouse Listener.

Mouse Motion Event Methods

The MouseMotionListener(in the API reference documentation) interface and its corresponding adapter class, MouseMotionAdapter(in the API reference documentation), contain two methods:
void mouseDragged(MouseEvent)
Notifies the listener ...
void mouseMoved(MouseEvent)
Notifies the listener ...

Examples of Handling Mouse Motion Events

The following applet demonstrates mouse motion events. [describe applet]

[applet goes here]


Try this:
  1. Do something...

You can find the applet's code in MouseMotionDemo.java. 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 Class

Each mouse motion event method has a single parameter -- and it's not called MouseMotionEvent! Instead, mouse motion event methods use MouseEvent(in the API reference documentation) objects. See Writing a Mouse Listener for information about the MouseEvent class.


Previous | Next | Trail Map | To 1.1 -- And Beyond! | GUI Changes: The AWT Grows Up