package 回答;import java.awt.Color;
import java.awt.Frame;public class TestFrame extends Frame{ public void show(){
this.setSize(600, 800);
this.setBackground(Color.gray);
// this.setVisible(true);
this.setVisible(true);
}

public static void main(String[] args) {
TestFrame t = new TestFrame();
t.show();
}
}
报出栈溢出错误  我无语了  这都能错  以前经常做没事  现在。

解决方案 »

  1.   

    不要用 show(),这个方法是Frame本身就有的(而且被废弃)。换个名字吧,比如:showFrame()。
      

  2.   

    show是一个方法名 换个。
    五秒钟关闭用Thread.sleep(5000)
      

  3.   

    加个线程就是了!!!import java.awt.Color;
    import javax.swing.JFrame;public class TestFrame extends JFrame{ public void init(){
    this.setSize(600, 800);
    this.setBackground(Color.gray);
    this.setVisible(true);
    new Close().start();
    } public class Close extends Thread{ public void run(){
    for(int i=0;i<5;i++){
    try{
    System.out.println((5-i)+"秒后关闭!");
    Thread.sleep(1000);//线程暂停1S
    }catch (InterruptedException e) {
    }
    }
    dispose();
    }
    } public static void main(String[] args) {
    TestFrame t = new TestFrame();
    t.init();
    }
    }