JFrame简单的例子

来源:互联网 发布:jmeter 引用java文件 编辑:程序博客网 时间:2024/04/29 20:23
public class MyJFrameTest extends JFrame {


private static final long serialVersionUID = 8279425225935892836L;

JButton jbt = null;

/**
* Default Constructor
*/
public MyJFrameTest(){
//标题
this.setTitle("hello world!");
//设置大小 按像素计算
this.setSize(600,400);
//设置初始位置
this.setLocation(400, 150);
//添加按钮
jbt = new JButton("我的按钮1");
this.add(jbt);
//默认关闭方法  jvm也退出
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//显示
this.setVisible(true);
}

/**
* Main Method
* @param args
*/
@SuppressWarnings("unused")
public static void main(String[] args) {
MyJFrameTest myJfTest = new MyJFrameTest();
}


}
0 0
原创粉丝点击