-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestMouseEvents.java
58 lines (58 loc) · 1.15 KB
/
TestMouseEvents.java
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
52
53
54
55
56
57
58
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
//<applet code="TestMouseEvents" width=400 height=400></applet>
public class TestMouseEvents extends Applet implements MouseListener,MouseMotionListener,MouseWheelListener
{
String msg="";
public void init()
{
addMouseListener(this);
addMouseMotionListener(this);
addMouseWheelListener(this);
}
public void mouseClicked(MouseEvent me)
{
msg="Mouse Clicked";
repaint();
}
public void mouseEntered(MouseEvent me)
{
msg="Mouse Entered";
repaint();
}
public void mouseExited(MouseEvent me)
{
msg="Mouse Exited";
repaint();
}
public void mousePressed(MouseEvent me)
{
msg="Mouse Pressed";
repaint();
}
public void mouseReleased(MouseEvent me)
{
msg="Mouse Released";
repaint();
}
public void mouseDragged(MouseEvent me)
{
msg="Mouse Dragged";
repaint();
}
public void mouseMoved(MouseEvent me)
{
msg="Mouse moved";
repaint();
}
public void mouseWheelMoved(MouseWheelEvent me)
{
msg="dont touch that wheel!!!!";
repaint();
}
public void paint (Graphics g)
{
g.drawString(msg,20,40);
}
}