聊天框java代码 java简单的聊天窗口代码

在java里编写聊天软件的图像界面代码怎么写如果你问的是怎么写界面的代码,那么 如果不需要太复杂 这样就可以:
JFrame frame = new JFrame(name);//窗口
JTextField jtf; // 文本条
JTextArea jta; //文本域 。
frame.setSize(400, 300); //大小
jta = new JTextArea(); //文本域
jta.setEditable(false); //不可编辑
jtf = new JTextField();//文件条
如果你问的是整个程序的代码 那就先把分加到100吧 而且就算100估计也没人会来给你写
因为很麻烦的
请问能不能帮我写一个Java的聊天窗口文件源代码,不要很复杂,只要能运行 , 聊天就行了!我用淘宝金币换,谢话说网上真聊天框java代码的好多啊...
package client;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class ClientFrame extends JFrame{
private JTextArea allmsg;
private JTextField welcome,copyright,chatmsg;
private JButton send;
private JScrollPane js;
private boolean isConnected = true;
public DataOutputStream out;
public DataInputStream in;
public Socket s = null;
String nic;/*-- 保存用户昵称 --*/
/**
* 初始化客户端资源
* 1.获取从LoginFrame传递过来的参数
* 2.初始化界面元素
* 3.初始化通信所需要的资源 EG:输入/输出流(DataInputStream/DataOutputStream)
* */
public ClientFrame(String name,Socket socket)
{
this.setSize(310,660);
this.setLocation(290,50);
this.setTitle("聊天室客户端"+name+"");/*-- 指定窗口的标题 --*/
this.s = socket;/*-- 接收从LoginFrame中传递过来的Socket --*/
this.nic = name+" 说: ";
welcome = new JTextField(""+name+" 欢迎您来到聊天室 ",100);
welcome.setBackground(Color.blue);
welcome.setEnabled(false);
copyright = new JTextField("-----all copyright @ TOP-king-----");
copyright.setEnabled(false);
allmsg = new JTextArea();
allmsg.setEditable(false);
allmsg.append("系统消息: 欢迎登录在线聊天室 \n");
js = new JScrollPane(allmsg);//为JTextArea添加滚动条
chatmsg = new JTextField("在此输入聊天信息");
chatmsg.addActionListener(new listen());
send = new JButton("发送");
send.addActionListener(new listen());/*-- 添加事件监听器 --*/
try {
out = new DataOutputStream(s.getOutputStream());
in = new DataInputStream(s.getInputStream());
} catch (IOException e) {JOptionPane.showMessageDialog(null, "系统异常","错误",JOptionPane.OK_CANCEL_OPTION);}
addcomponettocontainer();
/*-- 当用户关闭窗口时进行相关的处理 eg:Socket Data(Input/Output)Stream 的关闭--*/
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
sendmsg("quitlogout");/*-- 向服务器端发送关闭信息 --*/
isConnected = false;
destory();/*-- 销毁窗口资源 --*/
}
});
new Thread(new linread()).start();/*-- 启动读取信息线程 --*/
}
public void addcomponettocontainer()
{
Container c = this.getContentPane();
c.setLayout(null);
welcome.setBounds(75,10,150,20);
js.setBounds(10,50,280,500);
chatmsg.setBounds(10,560,180,30);

推荐阅读