gui编程实战——qq聊天界面1

 1 public class testDemo_2 extends JFrame{
 2     JTextArea jta=null;                       //多行文本框组件
 3     JScrollPane jsp=null;                     //滚动文本框
 4     JPanel jp1=null;
 5     JComboBox jcb=null;                       //下拉文本框
 6     JTextField jtf=null;
 7     JButton jb1=null;
 8     public static void main(String[] args){
 9         testDemo_2 demo=new testDemo_2();
10     }
11     
12     //构造函数
13     public testDemo_2(){
14         jta=new JTextArea();
15         jsp=new JScrollPane(jta);
16         jp1=new JPanel();
17         String []chatter={"布什","拉登"};
18         jcb=new JComboBox(chatter);
19         jtf=new JTextField(10);
20         jb1=new JButton("发送");
21         
22         //设置布局
23         //添加组件
24         jp1.add(jcb);
25         jp1.add(jtf);
26         jp1.add(jb1);
27         //加入JFrame
28         this.add(jsp);
29         this.add(jp1,BorderLayout.SOUTH);
30         //属性
31         this.setSize(300,200);
32         this.setTitle("腾讯qq");
33         this.setIconImage((new ImageIcon("image/qq.jpg")).getImage());
34         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
35         
36         this.setVisible(true);
37     }
38 }

运行效果如下:

posted @ 2017-08-03 14:34  最咸的鱼  阅读(591)  评论(0编辑  收藏  举报