L10-MouseListener

L10-MouseListener - CSE205 Concepts of Computer Science and...

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

View Full Document Right Arrow Icon
CSE205 Concepts of Computer Science and Data Structures
Background image of page 1

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

View Full DocumentRight Arrow Icon
Mouse Events We can write a GUI program to capture and respond to events that are fired when the user interacts with the computer’s mouse For example: moving the mouse, clicking the mouse button, pressing the mouse, and etc…
Background image of page 2
MouseListener Mouse Listener and Mouse Motion Listener -- defined in java.awt.event package. If we want to obtain a user input through a mouse, we need to create an object of a listener class that implements MouseListener interface or MouseMotionListener interface. To define what should happen for each mouse event, a method of MouseListener or MouseMotionListener should be defined.
Background image of page 3

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

View Full DocumentRight Arrow Icon
A mouse button is pressed down. void mousePressed(MouseEvent event) A mouse button is released. void mouseReleased(MouseEvent event) A mouse button is pressed down and released without moving the mouse in between. void mouseClicked(MouseEvent event) A mouse pointer is moved onto (over) a component. void mouseEntered(MouseEvent event) A mouse pointer is moved out of a component. void mouseExited(MouseEvent event)
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

L10-MouseListener - CSE205 Concepts of Computer Science and...

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

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