public class helloworld extends Applet {
  boolean isStandalone = false;
  JLabel jLabel1 = new JLabel();
  XYLayout xYLayout1 = new XYLayout();
  JButton jButton1 = new JButton();
  //Get a parameter value
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
      (getParameter(key) != null ? getParameter(key) : def);
  }  //Construct the applet
  public helloworld() {
  }
  //Initialize the applet
  public void init() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception {
    jLabel1.setText("helloworld");
    this.setLayout(xYLayout1);
    jButton1.setText("jButton1");
    this.add(jLabel1, new XYConstraints(155, 145, -1, -1));
    this.add(jButton1,  new XYConstraints(153, 119, -1, -1));
  }
  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  }
  //Get parameter info
  public String[][] getParameterInfo() {
    return null;
  }
  //Main method
  public static void main(String[] args) {
    helloworld applet = new helloworld();
    applet.isStandalone = true;
    Frame frame;
    frame = new Frame() {
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
        }
      }
      public synchronized void setTitle(String title) {
        super.setTitle(title);
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
      }
    };
    frame.setTitle("Applet Frame");
    frame.add(applet, BorderLayout.CENTER);
    applet.init();
    applet.start();
    frame.setSize(400,320);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
    frame.setVisible(true);
  }

解决方案 »

  1.   

    IE是不支持swing,除非你用htmconvert进行转换。
      

  2.   

    那我应该用什么控件,AWT可不可以呢?另外,你说的“htmconvert进行转换”如何实现?
      

  3.   

    你用awt就可以了。
    但htmconvert我也没有试过,但我知道它是可以的。
    你去查找一下关键字htmconvert。
      

  4.   

    Hi:
       IE不支持swing,only 支持awt.
       one easy way is change , JApplet--->Applet,JButton--->Button,JLabel--->Label,JXXXX--->XXXX
       good luck!!
      

  5.   

    不需要,下载sun公司的java plug-in,安装后就可以了。