码迷,mamicode.com
首页 > 其他好文 > 详细

GUI(Frame)

时间:2015-05-09 14:53:45      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

import java.awt.*;

/*

 * 创建图形界面:

 */

public class AwtDemo {

           public static void main(String[] args)

                    {   

                           /*  

                            * 创建Frame窗体  

                            */   

                          Frame f=new Frame("my awt");

                                  /*   

                                   * 对窗体进行基本设置:比如大小、位置、布局   

                                   */  

                            f.setSize(500, 400);

                            f.setLocation(300, 200);

                            f.setLayout(new FlowLayout());  

                                /*  

                                  * 定义组件  

                                  */  

                             Button b=new Button("我是一个按钮");  

                                  /*  

                                   * 将组件通过窗体的add方法,添加到窗体中   

                                   */  

                              f.add(b);  

                                    /*   

                                     * 让窗体显示,通过setVisible(true)   

                                     */  

                               f.setVisible(true);  

                               //System.out.println("Hello  World!");

                    }

}

GUI(Frame)

标签:

原文地址:http://www.cnblogs.com/binglin/p/4489873.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!