-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoEvent.java
More file actions
51 lines (45 loc) · 910 Bytes
/
DemoEvent.java
File metadata and controls
51 lines (45 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.awt.*;
import java.awt.event.*;
class DemoEvent extends Frame implements MouseListener
{
Panel p;
Button b1,b2;
public DemoEvent()
{
super("Welcome");
setVisible(true);
setSize(400, 400);
p = new Panel();
add(p);
b1 = new Button("Hi");
p.add(b1);
b2 = new Button("Bye");
p.add(b2);
b1.addMouseListener(this);
b2.addMouseListener(this);
}
public void mouseExited(MouseEvent e)
{
p.setBackground(Color.yellow);
}
public void mouseEntered(MouseEvent e)
{
p.setBackground(Color.red);
}
public void mousePressed(MouseEvent e)
{
p.setBackground(Color.white);
}
public void mouseReleased(MouseEvent e)
{
p.setBackground(Color.black);
}
public void mouseClicked(MouseEvent e)
{
p.setBackground(Color.pink);
}
public static void main(String args[])
{
DemoEvent d = new DemoEvent();
}
}