java swing的图形界面hello world

 时间:2026-04-24 04:30:05

1、使用eclipse创建一个项目名字为Test,并创建com.cn.Test 类。

java swing的图形界面hello world

2、编写main方法:

public class Test{

public static void main(String[] args) {

// TODO Auto-generated method stub 

}

}

java swing的图形界面hello world

3、继承JFrame。public class Test extends JFrame

java swing的图形界面hello world

4、创建一个窗口,代码: mainFrame = new JFrame("第一个程序");

mainFrame.setSize(500,500);

java swing的图形界面hello world

5、向窗口中增加面板,增加lable:

 JPanel panel = new JPanel();

mainFrame.add(panel);

  JLabel userLabel = new JLabel("hello world");

  userLabel.setBounds(20,30,80,25);

  panel.add(userLabel);

java swing的图形界面hello world

6、 设置窗口可见。mainFrame.setVisible(true); 

java swing的图形界面hello world

7、运行程序,弹出窗口 hello world。完成第一个java swing程序。

java swing的图形界面hello world

  • 干煸四季豆(豆角)
  • 清洗机种类介绍
  • 企业淡季促销的意义
  • 如何更改文档中图片的查看格式
  • 做一个优秀的谈话者
  • 热门搜索
    北海银滩旅游攻略 贵州镇远旅游攻略 伊春旅游网 丽江旅游攻略自助游 阳江闸坡旅游 芒果旅游 内蒙古的旅游景点 浙江台州旅游景点大全 去朝鲜旅游多少钱 金坛旅游网