GUI(Frame)

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!");

                    }

}

posted @ 2015-05-09 14:25  冰林  阅读(179)  评论(0编辑  收藏  举报