我用applet小程序编了一个池塘夜雨场景,可是把它放到JFrame里之后 声音播放不了 提示getCodeBase()异常,哪位高手能指教一下是怎么回事呢?感谢ing...
package javaclass;
import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.applet.AudioClip;
 public class 雨滴 extends  JApplet implements Runnable{

Image offimg=null;
Graphics offgc=null;
private AudioClip thunders[]=new AudioClip[5];
private AudioClip raining[]=new AudioClip[3];
private boolean start=false;
private int width=1024;
private int height=768;
private int counts=1000;
private rain[] rains=new rain[1000];
private int rsize=2;
public void init()
{
offimg=this.createImage(width+100, height);
offgc =offimg.getGraphics();
for(int i=0;i<5;i++)
{
thunders[i]=getAudioClip(getCodeBase(),"thunder"+i+".wav");
}
for(int i=0;i<3;i++)
{
raining[i]=getAudioClip(getCodeBase(),"rain"+i+".wav");
}
for(int i=0;i<counts;i++)
{
rains[i]=new rain(offgc,(int)(Math.random()*(width+200)),(int)(Math.random()*500),rsize*7,height-350);
}
}
public void start()
{
start=true;
new Thread(this).start();
raining[rsize].loop();
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(offimg,0,0,this);
}
public void run()
{
while(start)
{
boolean isthunder=false;
if(0==(int)(Math.random()*250-rsize*50))
{
offgc.setColor(Color.GRAY);
isthunder=true;
}
else offgc.setColor(Color.black);
offgc.fillRect(0, 0, width+100,height);
for(int i=0;i<counts/(3-rsize);i++) rains[i].falling(rsize);
repaint();
if(isthunder)thunders[rsize+(int)(Math.random()*2)].play();
try{Thread.sleep(40);}catch(Exception e){}
}
}
public void stop()
{
start=false;
}
private void change(int size)
{
this.rsize=size;
}
}
/*雨滴啊*/
class rain
{
static  long c=0;
private int f=99;
private int mx=0;
private int my=0;
private int mrate;
private int mgrd;
private int gv=3;
private double g=3.6;
private int xpt=0;
private int ypt=0;
private int dx=0;
private int dy=0;
private int offx=0;
private int offy=0;
private int cx=0;
private int cy=0;
private int ch=2;
private int cw=3;
private int size=0;
private int rate=0;
private double direct=0.0;
private int ground=0;
private Graphics gc=null;
private Color colo=null;
public rain(Graphics g,int x,int y,int rate,int grd)
{
init(g,x,y,rate,grd);
}
public void init(Graphics g,int x,int y,int rate,int grd)
{
this.mx=x;
this.my=0;
this.mrate=rate;
this.mgrd=grd;
this.gc=g;
this.xpt=x+(int)(Math.random()*100)%3;
this.ypt=y+(int)(Math.random()*100)%100;
this.rate=rate+(int)(Math.random()*100)%3+(int)(Math.sqrt(ypt*this.g*2));
this.direct=(rate+(int)(Math.random()*100)%2)*Math.PI/180;;
this.ground=grd+(int)(Math.random()*100)%150;
dx=(int)(size*Math.sin(direct));
dy=(int)(size*Math.cos(direct));
colo=new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255));
}
public void falling(int rs)
{
this.size=rs*3+(int)(Math.random()*100)%3;
if(ypt<ground)
{
offx=(int)(rate*Math.sin(direct));
offy=(int)(rate*Math.cos(direct));
gc.setColor(colo);
int x0=xpt+dx;
int y0=ypt-dy;
if(ground-ypt>10)
gc.drawLine(xpt, ypt, x0, y0);
xpt-=offx;
ypt+=offy;
rate+=gv;
}
else 
{
f=1;
cx=xpt;
cy=ypt;
cw=1+rs;
ch=rs;
c++;
init(gc,mx,my,mrate,mgrd);
}
if(f<5)
{
gc.drawOval(cx-cw, cy-ch, 2*cw,2*ch);
cw+=f*0.5;ch+=(f-1)*0.5;
gc.drawOval(cx-cw, cy-ch, 2*cw,2*ch);
f++;
}
}
public static long counts()
{
return c;
}
}//JFrame代码
ackage class_rain;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java_class.*;
public class rain {
public static void main(String[]a)
{
雨滴 r=new 雨滴();
JFrame j=new JFrame("池塘夜雨");
j.setVisible(true);
Container c=j.getContentPane();
c.setLayout(new BorderLayout());
c.add(r);
r.init();
r.start();
j.pack();
j.setSize(1000, 700);

}}
还没有来的及写注释 对付看吧