/**
* @param args
*/
import java.applet.*;
import java.awt.Graphics;
import java.awt.Image;
public class AppletTest extends Applet{
private Image ima[] = new Image[2];
int i;
Graphics g = this.getGraphics();
public void init(){
//如果调用的是getCodeBase()方法:图片要放在目录的bin文件夹下
//如果调用的是getDocumentBase()方法:图片要放在html目录下
System.out.println("url的地址为:" + getCodeBase());
ima[0] = getImage(getCodeBase(), "1.gif");
ima[1] = getImage(getCodeBase(), "2.gif");
}
public void start(){
i = 0;
System.out.println("AppletTest.start()");
}
public void stop(){
}
public void destory(){
}
public void paint(Graphics g){
System.out.println("AppletTest.paint()");
//这个和j2me不一样 最后不是传入的锚点,而是调用者的实例对象
i = 0;
while(true){
System.out.println("AppletTest.paint()" + i);
g.drawImage(ima[i%2], 50, 50, this);
i ++;
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(i == 2){
i = 0;
}
}
//repaint();
}
}