-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJLab0901.java
More file actions
54 lines (53 loc) · 1.44 KB
/
Copy pathJLab0901.java
File metadata and controls
54 lines (53 loc) · 1.44 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
import java.applet.Applet;
import java.awt.*;
public class JLab0901 extends Applet{
private int initCnt;
private int startCnt;
private int stopCnt;
private int destroyCnt;
private int paintCnt;
public void LifeCycle(){
initCnt = 0;
startCnt = 0;
stopCnt = 0;
destroyCnt = 0;
paintCnt = 0;
}
public void init(){
initCnt++;
System.out.println("init() invoked "+initCnt+" time(s)");
}
public void destroy(){
destroyCnt++;
System.out.println("destroy() invoked "+destroyCnt+" time(s)");
}
public void start(){
startCnt++;
System.out.println("start() invoked "+startCnt+" time(s)");
}
public void stop(){
stopCnt++;
System.out.println("stop() invoked "+ stopCnt +" time(s)");
}
public void paint(Graphics g){
paintCnt++;
System.out.println("paint() invoked "+paintCnt+" time(s)");
g.drawLine(20, 200, 300, 200);
g.drawLine(20, 200, 20, 200);
g.drawLine(20, 170, 15, 170);
g.drawLine(20, 140, 15, 140);
g.drawLine(20, 110, 15, 110);
g.drawLine(20, 80, 15, 80);
g.drawLine(20, 50, 15, 50);
g.drawString("init()",25, 213);
g.drawString("start()",75, 213);
g.drawString("stop()",125, 213);
g.drawString("destroy()",175, 213);
g.drawString("paint()",235, 213);
g.fillRect(25,200-initCnt*30,40,initCnt*30);
g.fillRect(75,200-startCnt*30,40,startCnt*30);
g.fillRect(125,200-stopCnt*30,40,stopCnt*30);
g.fillRect(175,200-destroyCnt*30,40,destroyCnt*30);
g.fillRect(235,200-paintCnt*30,40,paintCnt*30);
}
}