把所以的IE窗口,都关掉,重新打开。理由是:所有的IE共一个session和一些存放IE的信息,当你第一次读如.class文件北读入内存,当所有的IE窗口关闭是,才摧毁session和她保持的那些信息。我以前写applet的时候,发现改了有时候等于没改,记住,用IE 调试applet时候,
重新读入applet.class需要关闭所有IE窗口。调试自己的窗体可以用bruceekcel的一个框架:
import javax.swing.*;
import java.awt.event.*;public class Console {
  // Create a title string from the class name:
  public static String title(Object o) {
    String t = o.getClass().toString();
    // Remove the word "class":
    if(t.indexOf("class") != -1)
      t = t.substring(6);
    return t;
  }
  public static void setupClosing(JFrame frame) {
    // The JDK 1.2 Solution as an 
    // anonymous inner class:
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
    // The improved solution in JDK 1.3:
    // frame.setDefaultCloseOperation(
    //     EXIT_ON_CLOSE);
  }
  public static void 
  run(JFrame frame, int width, int height) {
    setupClosing(frame);
    frame.setSize(width, height);
    frame.setVisible(true);
  }
  public static void 
  run(JApplet applet, int width, int height) {
    JFrame frame = new JFrame(title(applet));
    setupClosing(frame);
    frame.getContentPane().add(applet);
    frame.setSize(width, height);
    applet.init();
    applet.start();
    frame.setVisible(true);
  }
  public static void 
  run(JPanel panel, int width, int height) {
    JFrame frame = new JFrame(title(panel));
    setupClosing(frame);
    frame.getContentPane().add(panel);
    frame.setSize(width, height);
    frame.setVisible(true);
  }

解决方案 »

  1.   

    首先感谢wfwtiger提出的问题,不过我不知道如何答,因为我的applet从来没有再ie上面成功测试过。
    其次说明一下我的情况:当我用ie打开包含applet的htm文件时,在applet位置上没有任何显示,当鼠标移到那个位置时,ie下面提示class xxx not found,我不知道是什么原因,后来我看书上所要一个htmlconverter的来把html重新转化一下,但是我按照书上的命令:java htmlconverter xxx.htm 把html文件转化时,系统提示出错:Exception in thread "main" java.lang.NoClassDefFoundError: htmlconventer
    我的classpath为:setclasspath=d:\jdk\lib\dr.jar;d:\jdk\lib\tools.jar;d:\jdk\bin;d:\jdk\converter\htmlconverter.jar;
    我正的不知道如何解决这个问题?       
    wfwtiger,sunnyby,请告诉我该如何作,小弟不胜感激!
      

  2.   

    事实上,你可以想象,当你把这个applet放到网上。显然这个applet的class文件是在你的服务器上的。而别人从网上启动这个有applet的页时,他就能看到这个applet了,这并不是因为你运行的是服务器上的class文件,而是,客户端从服务器哪里down下了这个class文件,也就是说,这个class文件事实上再客户端机器里存在了。我记得好像是在 c:\......\temp这个目录下。有这么一个同名的class
    你不妨在机器上检索一下
      

  3.   

    将你的程序修改一下:调用applet 时,设一下scope属性 为page,然后再试试看。
      

  4.   

    在重申:
    1。这个问题我遇到过,如果你用同样的方法没有解决,那我实在是。。遗憾,
    或者是,还有什么scope的之类的东西没有设置2。不要用IE来调试自己的Applet,以前我这样用,后来甚至每次都要怀疑,
    IE是不是重新读去了我的class,这种怀疑实在是额外的负担。所以,我现在一直
    用bruceeckel的frame调试自己的窗口程序。个人习惯,仅供参考