【Java开源代码栏目提醒】:本文主要为网学会员提供AppMethodDemo.java,希望对需要AppMethodDemo.java网友有所帮助,学习一下!
import java.awt.*;
import java.applet.*;
public class AppMethodDemo extends Applet {
int initCnt = 0;
int startCnt = 0;
int stopCnt = 0;
int destroyCnt = 0;
int paintCnt = 0;
public void init() {
this.setBackground(Color.LIGHT_GRAY);
initCnt ++;
}
public void start() {
startCnt ++;
}
public void stop() {
stopCnt ++;
}
public void destroy() {
destroyCnt ++;
}
public void paint(Graphics g) {
paintCnt ++;
g.setFont(new Font(null, Font.BOLD, 14));
g.drawString("Applet方法调用次数统计", 10, 20);
g.setFont(new Font(null, Font.PLAIN, 12));
g.setColor(Color.BLUE);
g.drawString("init (" + initCnt + ")", 10, 50);
g.fillRect(10, 54, 10 + initCnt*50, 5);
g.drawString("start (" + startCnt + ")", 10, 80);
g.fillRect(10, 84, 10 + startCnt*50, 5);
g.drawString("stop (" + stopCnt + ")", 10, 110);
g.fillRect(10, 114, 10 + stopCnt*50, 5);
g.drawString("destory (" + destroyCnt + ")", 10, 140);
g.fillRect(10, 144, 10 + destroyCnt*50, 5);
g.drawString("pain (" + paintCnt + ")", 10, 170);
g.fillRect(10, 174, 10 + paintCnt*50, 5);
}
}
上一篇:
AppMain.java
下一篇:
病理学实验课多样化教学方法探讨