[黑马] 第1天 ---- Swing界面

来源:互联网 发布:网络搭建教程 编辑:程序博客网 时间:2024/05/19 19:44
------- android培训 java培训期待与您交流! ----------

package com.test1;


/**  QQ聊天
 */
import java.awt.*;
import javax.swing.*;
public class Demo8_10 extends JFrame 
{
JTextArea jta = null;
JScrollPane jsp = null;
JPanel jp1 = null;
JComboBox jcb = null;
JTextField jtf = null;
JButton jb = null;
public static void main(String[] args) 
{
Demo8_10 demo = new Demo8_10();
}
//构造
public Demo8_10()
{
//创建组件
jta = new JTextArea();
jsp = new JScrollPane(jta);
jp1 = new JPanel();
String[] chatter = {"布什","拉登"};
jcb = new JComboBox(chatter);
jtf = new JTextField(10);
jb = new JButton("发送");

//设置布局
//添加组件
jp1.add(jcb);
jp1.add(jtf);
jp1.add(jb);

//加入JFrame
this.add(jsp);
this.add(jp1,BorderLayout.SOUTH);

//大小
this.setSize(300,200);
this.setIconImage((new ImageIcon("image/未命名.jpg")).getImage());
this.setTitle("腾讯QQ");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}




------- android培训 java培训期待与您交流! ----------