-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClickEvent6.java
More file actions
45 lines (39 loc) · 1.13 KB
/
ClickEvent6.java
File metadata and controls
45 lines (39 loc) · 1.13 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
import java.awt.*;
import java.awt.event.*;
class ClickCircles extends Frame implements MouseListener{
int xAxis = 4;
int yAxis = 4;
int radius = 5;
int max = 200;
ClickCircles(){
setSize(500, 400);
addMouseListener(this);
setVisible(true);
}
public void paint(Graphics g){
if(radius < max){
g.drawOval(xAxis- radius, yAxis-radius, 2*radius, 2*radius);
radius++;
try {
Thread.sleep(10); // Adjust the animation speed here.
} catch (InterruptedException e) {
e.printStackTrace();
}
repaint();
}
}
public void mouseClicked(MouseEvent e){
xAxis = e.getX();
yAxis = e.getY();
radius = 5;
repaint();
}
// mendatory to define all these methods from interface
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public static void main(String args[]){
ClickCircles cc = new ClickCircles();
}
}