现在正在学习Applet,今天照这个课本的写了,但是运行时提示异常:求大神指点下面是eclipse的代码:
package com.applet.li;
import java.applet.*;
import java.awt.Graphics;
import java.awt.Image;
public class Test5 extends Applet implements Runnable{
    static final long serialVersionUID=1;
    Image background;
    Thread t;
    String text;
    boolean loop=true;
    int delay;   
    public void init(){
     background=getImage(getCodeBase(),getParameter("background"));
     text=getParameter("text");
     delay=Integer.parseInt(getParameter("delay"));
    }
    public void start(){
     t=new Thread(this);
     t.start();
    }
    public void stop(){
     loop=false;
    }
    public void run(){
     int x=0;
     Graphics g=getGraphics();
     Image buffer=createImage(getWidth(),getHeight());
     Graphics gp=buffer.getGraphics();
     while(loop){
     gp.drawImage(background, 0, 0, getWidth(), getHeight(), this);
     gp.drawString(text, x, 50);
     g.drawImage(buffer, 0, 0, this);
     x+=2;
     if(x>=getWidth()){
     x=0;
     }
     try{
     Thread.sleep(delay);
     }catch(Exception e){
    
     }
     }
    }
}下面是HTML的代码:
<html>
<body>
<!--加载test5.class文件-->
<Applet code="Test5.class",width="200",height="200">
<!--传入参数-->
<param name="background" value="bullet.gif" />
<param name="text" value="我是一个优秀的程序员" />
<param name="delay" value="100" />
</Applet>
</body>
</html>