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();
}
}
报出栈溢出错误 我无语了 这都能错 以前经常做没事 现在。
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();
}
}
报出栈溢出错误 我无语了 这都能错 以前经常做没事 现在。
五秒钟关闭用Thread.sleep(5000)
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();
}
}