Slides0316 - the event GUI - MouseListener • Example:...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Slides 3/16 COP 3330
Background image of page 1

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

View Full DocumentRight Arrow Icon
Topics Responding to the mouse
Background image of page 2
Assignment #4 Assignment #4 handed out in class Assignment #4 is also available on WebCourses
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
MouseEvent MouseEvents have many useful methods Perhaps the most useful are: - getX() - getY() These return the x and y coordinates of
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
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

This note was uploaded on 02/09/2010 for the course CS COP 3330 taught by Professor Douglass during the Spring '09 term at University of Central Florida.

Page1 / 10

Slides0316 - the event GUI - MouseListener • Example:...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online