• 大小: 2.13MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-06
  • 语言: Java
  • 标签: JAVA  QQ  飞秋  

资源简介

用java CS 模式实现的简单版的java实现的仿qq聊天程序,有上线下线弹窗提醒、聊天、上传头像、自动更新好友列表、自动加载好友信息、发送消息、发送文件等功能,减压后的文件夹下附有说明文件。 程序启动方法: 1、先打开目录SimpleChatServer 下的ChatServer.bat 2、然后再打开SimpleChatClient 下的ChatClient.bat

资源截图

代码片段和文件信息

package com.lee.client;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
import java.util.linkedList;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import javax.swing.filechooser.FileFilter;

import com.lee.comm.ClientTransfer;
import com.lee.comm.MyImageButton;
import com.lee.comm.MyImagePanel;
import com.lee.comm.MyMouseListener;
import com.lee.comm.ServerTransfer;
import com.lee.comm.user.User;
import com.lee.comm.util.frameUtil;
import com.lee.comm.util.ImageUtil;

/**
 *    聊天窗口
 * */
public class ClientChatframe extends Jframe{
private JTextArea txt_sign;
private JTextArea showArea;
private JTextArea inputArea;
private static final long serialVersionUID = 1L;
private Image image = null;
private static Image defaultUserImg = null;
private JPanel mainPanel;
private User user;
private ClientMainframe parentframe;
private ClientChatframe $this = this;
private JButton btn_minbtn_closebtn_upload;
private JProgressBar progressBar;
private MouseHander hander = new MouseHander(); 
private File selectedFile;
private boolean isSend = false;
private boolean isReceive = false;
private JLabel label_info;
private static int transFileSize = 1024; //傳輸的文件数组初始化大小

static
{
try {
defaultUserImg = ImageUtil.getDefaultUserImage();
} catch (Exception e) {
e.printStackTrace();
}
}

{
try {
image =  ImageUtil.getImageByPath(ImageUtil.systemImagePath(“square7.jpg“));
} catch (Exception e) {
e.printStackTrace();
}
}

public ClientChatframe(User user  ClientMainframe mainframe) throws Exception
{
super();
this.user = user;
this.parentframe = mainframe;
this.setUndecorated(true);
MyMouseListener draglistener = new MyMouseListener(this);
this.addMouseMotionListener(draglistener);
this.addMouseListener(draglistener);
init();
}

public void init() throws Exception
{
settitle(“聊天窗口:“+user.getNickName());
frameUtil.setframeLocationCenter(this 450 450);
//this.se

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-12-08 23:47  SimpleChat\
     目录           0  2013-12-08 23:46  SimpleChat\SimpleChatClient\
     文件         232  2013-11-26 15:32  SimpleChat\SimpleChatClient\.classpath
     文件         392  2013-12-08 22:07  SimpleChat\SimpleChatClient\.project
     目录           0  2013-12-08 23:46  SimpleChat\SimpleChatClient\.settings\
     文件         629  2013-11-26 15:31  SimpleChat\SimpleChatClient\.settings\org.eclipse.jdt.core.prefs
     文件          98  2013-12-08 23:27  SimpleChat\SimpleChatClient\ChatClient.bat
     目录           0  2013-12-08 23:46  SimpleChat\SimpleChatClient\bin\
     目录           0  2013-12-08 23:46  SimpleChat\SimpleChatClient\bin\com\
     目录           0  2013-12-08 23:46  SimpleChat\SimpleChatClient\bin\com\lee\
     目录           0  2013-12-08 23:46  SimpleChat\SimpleChatClient\bin\com\lee\client\
     文件        1973  2013-12-08 23:12  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientChatframe$1.class
     文件        1897  2013-12-08 23:12  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientChatframe$2.class
     文件        2072  2013-12-08 23:12  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientChatframe$3.class
     文件        4130  2013-12-08 23:12  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientChatframe$4.class
     文件        1165  2013-12-08 23:12  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientChatframe$5$1.class
     文件        6002  2013-12-08 23:12  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientChatframe$5.class
     文件        3043  2013-12-08 23:12  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientChatframe$MouseHander.class
     文件       11236  2013-12-08 23:12  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientChatframe.class
     文件        1904  2013-12-08 22:20  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientLoginframe$1.class
     文件        1615  2013-12-08 22:20  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientLoginframe$MouseHander.class
     文件        7232  2013-12-08 22:20  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientLoginframe.class
     文件        1511  2013-12-08 23:16  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientMainframe$1.class
     文件        1022  2013-12-08 23:16  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientMainframe$2.class
     文件        4702  2013-12-08 23:16  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientMainframe$MouseHander.class
     文件        5372  2013-12-08 23:16  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientMainframe$clientHandler.class
     文件       16415  2013-12-08 23:16  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientMainframe.class
     文件        1979  2013-12-08 22:07  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientRegistframe$1.class
     文件        1042  2013-12-08 22:07  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientRegistframe$2.class
     文件        1627  2013-12-08 22:07  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientRegistframe$MouseHander.class
     文件       10064  2013-12-08 22:07  SimpleChat\SimpleChatClient\bin\com\lee\client\ClientRegistframe.class
............此处省略223个文件信息

评论

共有 条评论