You are on page 1of 2

Name of Student: Ekambe Ganesh Roll No.

: 53
Experiment No.: 11 DOS:

Exercise
1. Write a program to change the background colour of Applet when
user performs events using mause

import java.awt.*;
import java.awt.event.*;
public class practical11_2 extends Frame implements MouseListener {
Label l;
String str;
practical11_2()
{ l = new
Label(); add(l);
addMouseListener(this);
setVisible(true);

setSize(400,400);
setLayout(new
FlowLayout());
}
public void mousePressed(MouseEvent e)
{
setBackground(Color.BLUE
); l.setText("BLUE");
}
public void mouseReleased(MouseEvent e)
{ setBackground(Color.red);
l.setText("RED");
}
public void mouseEntered(MouseEvent e) {
setBackground(Color.orange);
l.setText("ORANGE");
}
public void mouseExited(MouseEvent e)
{ setBackground(Color.green);
l.setText("Green");
}
public void mouseClicked(MouseEvent e)
{ setBackground(Color.CYAN);
l.setText("CYAN");
}
public static void main(String[] args)
{ new practical11_2();
}
}
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 11 DOS:

Output :

You might also like