class MyFrame extends javax.swing.JFrame{
public MyFrame(){
this.setTitle("我的自定义窗口"); //设置窗体的标题
this.setSize(500,400); //设置窗体的大小:宽和高
this.setVisible(true); //设置窗体可见
this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null); //设置居中
}
}
public class MyFrameDemo{
public static void main(String[] args){
MyFrame myFrame = new MyFrame();
}
}
开老师讲的敲了一遍!