Java 小程序在网页中出现notinited错误,编译没问题,困惑中...
下面是代码:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;
class DrawImageAnimator extends Frame
{
public DrawImageAnimator( String s )
{
super(s);
final String dir = "D:\\PIC ";
String [] files = new File(dir).list();
int num = files.length <=10? files.length : 10;
images = new Image[num];
for( int i=0; i <num; i++ )
images[i] = Toolkit.getDefaultToolkit().createImage(
dir + "\\ "+ files[i]);
setSize( 400, 700 );
show();
addWindowListener( new WindowAdapter(){
public void windowClosing(WindowEvent e ){
bStop = true;
System.exit(0);
}
});
thread = new MyThread();
thread.start();
}
public void paint(Graphics g)
{
g.drawImage( images[ curImage ], 0, 0, this );
}
private Image[] images;
private int curImage;
private boolean bStop;
private MyThread thread;
class MyThread extends Thread
{
public void run(){
while( ! bStop ){
repaint();
try{ sleep(1000); } catch(InterruptedException e){}
curImage ++;
if( curImage==images.length ) curImage=0;
}
}
}
public static void main(String args[])
{
Object f = new DrawImageAnimator( "DrawImageAnimator ");
}
}
------解决方案--------------------Eclips下能调出来,IE不出来说明不是程序代码的问题,不出来是什么状态呀,有没有错误信息呀,APPLET有个窗口呀,里边有没有异常信息呀,你要给大家说清楚呀,不然别人不好分析呀.我怀疑是不是你的APPLET的路径有问题。 我做APPLET很多的,一般刚APPLET都有遇到那些问题。