Example -- Applet with mouse drag and move events
In this example, the applet combines the functionalities from the previous
two examples. Both the mouseDragged and mouseMoved methods
are implemented to capture and handle the mouse drag and mouse move
events.
Listing 2.1.7 shows the source code for the above program. Move
the mouse within the applet. The mouse movement is tracked with the blue
filled rectangles. Press and drag the mouse within the applet. In this
case, the mouse movement is tracked and filled with the red ovals. In the
former case, the mouseMoved method handles the events and in the
latter case, the events are handled by the mouseDragged method.
|