GUI - MouseListener • You can have your program respond to interesting mouse events by having your class implement the interface MouseListener and registering with the GUI component that should respond to those events • This is very similar to ActionListener

GUI - MouseListener • MouseListeners can respond to five types of events-mouseClicked-mouseEntered-mouseExited-mousePressed-mouseReleased • All have return type void and have a MouseEvent as a parameter

This
preview
has intentionally blurred sections.
Sign up to view the full version.

This is the end of the preview.
Sign up
to
access the rest of the document.

Unformatted text preview: the event GUI - MouseListener • Example: Write a program that draws random lines around where the user clicks the Canvas GUI - MouseMotionListener • Have your class implement MouseMotionListener to respond to events such as moving the mouse and dragging the mouse GUI - MouseMotionListener • MouseMotionListeners respond to two events:-mouseMoved-mouseDragged • Both have return type void and have a MouseEvent as a parameter • If you implement a MouseMotionListener, expect to receive a LOT of these events GUI - MouseMotionListener • Example: Write a program that will draw lines on the canvas under the mouse cursor as it moves...
View
Full Document