PracticalNo11

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Practical No.

: 11

Practical Name: Write a program to demonstrate various mouse events using MouseListener and
MouseMotion listener interface.

Roll No.: 47

Student Name: Mavani Ashish Shantilal

Program:

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/* <APPLET CODE ="MouseDemo" WIDTH=300 HEIGHT=200> </APPLET> */
public class MouseDemo extends Applet implements MouseListener
{
Label l;
public void init()
{
setLayout(null);
l=new Label("Hello Mouse");
l.setBounds(50,150,200,100);
add(l);
}
public void mousePressed(MouseEvent e)
{
l.setText("Mouse Pressed no. of clicks:" + e.getClickCount() + "atposition" +
e.getX() + ","+ e.getY());
}
public void mouseReleased(MouseEvent e)
{
l.setText("Mouse Released; # of clicks:"+e.getClickCount());
}
public void mouseEntered(MouseEvent e)
{
l.setText("Mouse Entered");
}
public void mouseExited(MouseEvent e)
{
l.setText("Mouse exited");
}
public void mouseClicked(MouseEvent e)
{
l.setText("mouse clicked(# of clicks:"+e.getClickCount());
}
}
Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy