基于JFrame下建立的第一个java程序框架
import javax.swing.JFrame;//JFrame包
public class newFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
drawFrame jf = new drawFrame();
jf.setVisible(true);//设置可见性
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置关闭窗口退出相应的程序
}
}
class drawFrame extends JFrame
{
//在这个构造方法中设置框架的属性
public drawFrame()
{
this.setTitle("框架设计");//标题
this.setSize(600, 400);//设置窗口大小 关于坐标问题看下图
this.setLocationRelativeTo(null);//居中显示窗口
this.setResizable(false);//设置窗口的可调整性
}
}