实现代码:
import java.awt.*;
public class TestFrame {
public static void main(String[] args) {
// System.out.println("haha");
Frame f = new Frame("I love you!");
f.add(new Button("ok"));
f.setSize(300, 300);
f.setVisible(true);
try {
Thread.sleep(5000);
} catch (Exception e) {
e.printStackTrace();
}
f.dispose();
}
}
运行结果: