资源简介

可以实现多客户端交互,只需要其中一台计算机做服务器端(该机器同时也可以作为客户端),可以私聊和群聊(界面没有分开),界面可爱风

资源截图

代码片段和文件信息

package chat.client;

import java.applet.applet;
import java.applet.AudioClip;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
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.objectInputStream;
import java.io.objectOutputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URL;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ListCellRenderer;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.Border;
import javax.swing.border.titledBorder;

import chat.function.ChatBean;
import chat.util.ChatUtil;

class CellRenderer extends JLabel implements ListCellRendererject> {
private static final long serialVersionUID = 1L;

CellRenderer() {
setOpaque(true);
}

public Component getListCellRendererComponent(JList list object value
int index boolean isSelected boolean cellHasFocus) {

setBorder(BorderFactory.createEmptyBorder(5 5 5 5));// 加入宽度为5的空白边框

if (value != null) {
setText(value.toString());
int i=(int)(Math.random()*7);
switch(i){//头像
case 0:{setIcon(new ImageIcon(“src//images//1.jpg“));break;}
case 1:{setIcon(new ImageIcon(“src//images//2.jpg“));break;}
case 2:{setIcon(new ImageIcon(“src//images//3.jpg“));break;}
case 3:{setIcon(new ImageIcon(“src//images//4.jpg“));break;}
case 4:{setIcon(new ImageIcon(“src//images//5.jpg“));break;}
case 5:{setIcon(new ImageIcon(“src//images//6.jpg“));break;}
case 6:{setIcon(new ImageIcon(“src//images//8.jpg“));break;}
default:{setIcon(new ImageIcon(“src//images//7.jpg“));break;}
}

}
if (isSelected) {//选中改变颜色
setBackground(Color.pink );// 设置背景色new Color(255 255 153)
setForeground(Color.black);
} else {
// 设置选取与取消选取的前景与背景颜色.
setBackground(Color.white); // 设置背景色
setForeground(Color.black);
}
se

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-02 17:00  ChatNow\
     文件     2330746  2018-12-07 23:05  ChatNow Appilication.zip
     目录           0  2018-12-02 16:59  ChatNow\ChatClient\
     文件         232  2018-12-02 16:59  ChatNow\ChatClient\.classpath
     文件         386  2018-12-02 16:59  ChatNow\ChatClient\.project
     目录           0  2018-12-07 12:52  ChatNow\ChatClient\bin\
     目录           0  2018-12-02 16:59  ChatNow\ChatClient\bin\chat\
     目录           0  2018-12-02 16:59  ChatNow\ChatClient\bin\chat\client\
     文件        2310  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\CellRenderer.class
     文件        1041  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$1.class
     文件        2863  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$2.class
     文件        1594  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$3.class
     文件        1632  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$4.class
     文件        2926  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$5.class
     文件        5734  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$ClientInputThread$1.class
     文件        3246  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$ClientInputThread$2.class
     文件        4514  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$ClientInputThread.class
     文件         812  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom$UUListModel.class
     文件        9162  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\client\Chatroom.class
     目录           0  2018-12-02 16:59  ChatNow\ChatClient\bin\chat\function\
     文件        3058  2018-12-05 21:58  ChatNow\ChatClient\bin\chat\function\ChatBean.class
     文件         786  2018-12-02 16:59  ChatNow\ChatClient\bin\chat\function\ClientBean.class
     目录           0  2018-12-02 17:36  ChatNow\ChatClient\bin\chat\login\
     文件         736  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\login\ChatLogin$1.class
     文件         999  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\login\ChatLogin$2.class
     文件        3192  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\login\ChatLogin$3.class
     文件         931  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\login\ChatLogin$4.class
     文件        4192  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\login\ChatLogin.class
     文件         998  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\login\ChatResign$1.class
     文件         938  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\login\ChatResign$2.class
     文件        3207  2018-12-07 12:54  ChatNow\ChatClient\bin\chat\login\ChatResign$3.class
............此处省略87个文件信息

评论

共有 条评论