添加main()
public static void main(String[] args){
this.show();
this.setsize();
}

解决方案 »

  1.   

    如zhutg(天光) 说。具体如下:
    public static void main(String[] args) {
        MyApplet applet = new MyApplet();    JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(3); //EXIT_ON_CLOSE == 3
        frame.getContentPane().add(applet, BorderLayout.CENTER);
        applet.init();
        applet.start();
        frame.setSize(400, 300);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation( (d.width - frame.getSize().width) / 2,
                          (d.height - frame.getSize().height) / 2);
        frame.setVisible(true);
      }
      

  2.   

    applet是一个panel,你可以把它加入到一个frame中,再显示。其实,你只要知道applet是一个panel,我想下面的具体操作应该不用多说了吧!