-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMouseclick.java
44 lines (43 loc) · 1.02 KB
/
Mouseclick.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
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet code=Mouseclick width=650 height=500>
</applet>
*/
public class Mouseclick extends Applet
{
String msg="";
int mousex=0,mousey=0;
public void init()
{
Mymouseadapter a1=new Mymouseadapter(this);
addMouseListener(a1);
}
public void paint(Graphics g)
{
g.drawString(msg,mousex,mousey);
g.drawLine(110,210,210,129);
g.drawLine(310,210,210,129);
g.drawRect(110,210,200,200);
g.drawRect(180,320,50,90);
g.drawOval(142,275,30,30);
g.drawOval(242,275,30,30);
}
class Mymouseadapter extends MouseAdapter
{
Mouseclick mouseclick;
Mymouseadapter(Mouseclick mouseclick)
{
this.mouseclick=mouseclick;
}
public void mouseClicked(MouseEvent me)
{
mousex=me.getX();
mousey=me.getY();
msg="Mouse clicked at "+mousex+","+mousey;
showStatus("Mouse clicked at "+mousex+","+mousey);
repaint();
}
}
}