聊天窗口界面编写

/**
 * 聊天窗口
 */


package com.test1;

import javax.swing.*;
import java.awt.*;

public class Demo8_10_1 extends JFrame
{
   JTextArea jta = null;
   JPanel jp1 = null;
   JComboBox jcb = null;
   JButton jb = null;
   JTextField jtf = null;
   JScrollPane jsp = null;
	
	
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		Demo8_10_1  demo8_10_1 = new Demo8_10_1();

	}
	
	public Demo8_10_1()
	{
		jta = new JTextArea();//多行文本
		jsp = new JScrollPane(jta);//滚动窗格组件
		jp1 = new JPanel(); //面板
		String []chatter = {"aa","bb"};
		jcb = new JComboBox(chatter);
		jtf = new JTextField(10);
		jb = new JButton("发送");//按钮
		
		jp1.add(jcb);
		jp1.add(jtf);
		jp1.add(jb);
		
		this.add(jsp);
		this.add(jp1,BorderLayout.SOUTH);
		
		
		this.setSize(300,200);
		this.setTitle("聊天软件");
		this.setIconImage(new ImageIcon("pic/Sunset.jpg").getImage());
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
	
}

你可能感兴趣的:(聊天窗口界面编写)