-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRB20.java
More file actions
62 lines (62 loc) · 1.42 KB
/
Copy pathRB20.java
File metadata and controls
62 lines (62 loc) · 1.42 KB
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
59
60
61
62
// APPLETS // Cursor Graphics // // save images in buffer and repaint them to avoid erasing y mouse//
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class RB20 extends Applet implements MouseListener , MouseMotionListener
{
int x,y,a;
public void init()
{
y = x = a = 0;
addMouseListener(this);
addMouseMotionListener(this);
}
public void mousePressed(MouseEvent me)
{
x = me.getX();
y = me.getY();
showStatus("MOUSE PRESSED AT " + x + " , " + y);
repaint(x,y,50,50);
}
public void mouseReleased(MouseEvent me)
{
x = me.getX();
y = me.getY();
showStatus("MOUSE RELESED AT " + x + " , " + y);
repaint(x,y,50,50);
}
public void mouseEntered(MouseEvent me)
{
showStatus("MOUSE ENTERED");
}
public void mouseExited(MouseEvent me)
{
showStatus("MOUSE EXITED");
}
public void mouseClicked(MouseEvent me)
{
x = me.getX();
y = me.getY();
showStatus("MOUSE CLICKED AT " + x + " , " + y);
}
public void mouseMoved(MouseEvent me)
{
x = me.getX();
y = me.getY();
showStatus("MOUSE CURRENTLY AT " + x + " , " + y);
repaint(x,y,50,50);
}
public void mouseDragged(MouseEvent me)
{
x = me.getX();
y = me.getY();
a = (a + 1) % 15;
showStatus("MOUSE BEING DRAGGED AT " + x + " , " + y);
h.fillRect(50,50,50,50);
repaint(x,y,50,50);
}
public void paint(Graphics g)
{
g.fillRect(x+16+a,y+16+a,20,20);
}
}