0% found this document useful (0 votes)
40 views4 pages

Practical No-11

The MouseListener interface notifies objects of mouse events on components. It defines five abstract methods that are called when the mouse is clicked, entered, exited, pressed, or released on a component. Mouse events are represented by MouseEvent objects. The interface is in the java.awt.event package and allows objects to listen for and respond to mouse interactions on components.

Uploaded by

Sushant Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

Practical No-11

The MouseListener interface notifies objects of mouse events on components. It defines five abstract methods that are called when the mouse is clicked, entered, exited, pressed, or released on a component. Mouse events are represented by MouseEvent objects. The interface is in the java.awt.event package and allows objects to listen for and respond to mouse interactions on components.

Uploaded by

Sushant Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Practical No-11

MouseListener Interface
MouseListener Interface
• Mouse event occurs when a mouse related activity is
performed on a component such as clicking, dragging, pressing,
moving or releasing a mouse etc.
• Objects representing mouse events are created from
MouseEvent class.
• The Java MouseListener is notified whenever you change the
state of mouse.
• It is notified against MouseEvent.
• The MouseListener interface is found in java.awt.event
package. 
•  It has five methods.
1. public abstract void mouseClicked(MouseEvent e); -Invoked when the
mouse button has been clicked (pressed and released) on a component

2. public abstract void mouseEntered(MouseEvent e); - Invoked when


the mouse pointer enters a component
3. public abstract void mouseExited(MouseEvent e); -Invoked when the
mouse pointer exits a component
4. public abstract void mousePressed(MouseEvent e);-Invoked when a
mouse button has been pressed on a component
5. public abstract void mouseReleased(MouseEvent e); - Invoked when a
mouse button has been released on a component
• There are two types of events that MouseMotionListener can
generate.
• There are two abstract functions that represent these five
events. The abstract functions are : 

• void mouseDragged(MouseEvent e) : Invoked when a mouse


button is pressed in the component and dragged. Events are passed
until the user releases the mouse button.
• void mouseMoved(MouseEvent e) : invoked when the mouse
cursor is moved from one point to another within the component,
without pressing any mouse buttons.

You might also like