?? appletcycle.java
字號:
import java.applet.Applet;
import java.awt.*;
public class AppletCycle extends Applet{
int initCount=0,startCount=0,paintCount=0,stopCount=0,
destoryCount=0;
Graphics g1;
public void paint(Graphics g){
g.setColor(Color.white);
g.fillRect(0,0,size().width,size().height);
//paint app the standard parts of the graph
g.setColor(Color.red);
g.drawLine(100,20,100,200);
g.drawLine(100,200,300,200);
g.setColor(Color.gray);
g.drawString("Init Count",5,50);
g.drawString("Start Count",5,100);
g.drawString("Stop Count",5,150);
g.drawString("Destory Count",5,200);
//paint the grid lines
g.setColor(Color.lightGray);
for(int x=(100+20);x<300;x+=20){
g.drawLine(x,20,x,199);
}
//draw the bars for each of the stats
g.setColor(Color.black);
g.fillRect(100,30,initCount*20,30);
g.fillRect(100,80,startCount*20,30);
g.fillRect(100,130,stopCount*20,30);
g.fillRect(100,180,destoryCount*20,30);
}
public void update(Graphics g){
paint(g);
}
public void init(){
initCount++;
System.out.println("initCount="+initCount);
repaint();
}
public void start(){
startCount++;
System.out.println("startCount="+startCount);
repaint();
}
public void stop(){
stopCount++;
System.out.println("stopCount="+stopCount);
System.out.println("");
repaint();
}
public void destory(){
destoryCount++;
System.out.println("destoryCount="+destoryCount);
repaint();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -