package com.client.view;
import com.client.tools.ManageChatFrame;
import com.client.tools.ManageThread;
import com.common.Message;
import com.common.MsgType;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import java.awt.event.*;
import java.awt.*;
import java.io.IOException;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 聊天界面,点击“消息记录”按钮即可显示聊天记录,再次点击即可切换回图片
*/
public class Chat extends JFrame implements ActionListener,MouseListener {
private JPanel panel_north;//北部区域面板
private JLabel jbl_touxiang;//头像
private JLabel jbl_friendname;//好友名称
private JButton btn_exit, btn_min;//最小化和关闭按钮
//头像下方7个功能按钮(未实现)
private JButton btn_func1_north, btn_func2_north, btn_func3_north, btn_func4_north, btn_func5_north, btn_func6_north, btn_func7_north;
//聊天内容显示面板
private JTextPane panel_Msg;
private JPanel panel_south;//南部区域面板
private JTextPane jtp_input;//消息输入区
//消息输入区上方9个功能按钮(未实现)
private JButton btn_func1_south, btn_func2_south, btn_func3_south,btn_func4_south, btn_func5_south, btn_func6_south, btn_func7_south, btn_func8_south, btn_func9_south;
private JButton recorde_search;//查看消息记录按钮
private JButton btn_send, btn_close;//消息输入区下方关闭和发送按钮
private JPanel panel_east;//东部面板
private CardLayout cardLayout;//卡片布局
//默认东部面板显示一张图,点击查询聊天记录按钮切换到聊天记录面板
private final JLabel label1 = new JLabel(new ImageIcon("image/dialogimage/hh.gif"));
private JTextPane panel_Record;//聊天记录显示面板
private boolean isDragged = false;//鼠标拖拽窗口标志
private Point frameLocation;//记录鼠标点击位置
private String myId;//本人账号
private String myName;
private String friendId;//好友账号
private DateFormat df;//日期解析
public Chat(String myId, String myName, String friendId, String friendName) {
this.myId = myId;
this.friendId = friendId;
this.myName = myName;
df = new SimpleDateFormat("yyyy-MM-dd a hh:mm:ss");
//获取窗口容器
Container c = this.getContentPane();
//设置布局
c.setLayout(null);
//北部面板
panel_north = new JPanel();
panel_north.setBounds(0, 0, 729, 92);
panel_north.setLayout(null);
//添加北部面板
c.add(panel_north);
//左上角灰色头像
jbl_touxiang = new JLabel(new ImageIcon("image/dialogimage/huisetouxiang.png"));
jbl_touxiang.setBounds(10, 10, 42, 42);
panel_north.add(jbl_touxiang);
//头像右方正在聊天的对方姓名
jbl_friendname = new JLabel(friendName+"("+friendId+")");
jbl_friendname.setBounds(62, 21, 105, 20);
panel_north.add(jbl_friendname);
//右上角最小化按钮
btn_min = new JButton(new ImageIcon ("image/dialogimage/min.png"));
btn_min.addActionListener(e -> setExtendedState(JFrame.ICONIFIED));
btn_min.setBounds(668, 0, 30, 30);
panel_north.add(btn_min);
//右上角关闭按钮
btn_exit = new JButton(new ImageIcon ("image/dialogimage/exit.jpg"));
btn_exit.addActionListener(this);
btn_exit.setBounds(698, 0, 30, 30);
panel_north.add(btn_exit);
//头像下方功能按钮
//功能按钮1
btn_func1_north = new JButton(new ImageIcon("image/dialogimage/yuyin.png"));
btn_func1_north.setBounds(10, 62, 36, 30);
panel_north.add(btn_func1_north);
//功能按钮2
btn_func2_north = new JButton(new ImageIcon("image/dialogimage/shipin.png"));
btn_func2_north.setBounds(61, 62, 36, 30);
panel_north.add(btn_func2_north);
//功能按钮3
btn_func3_north = new JButton(new ImageIcon("image/dialogimage/tranfile.jpg"));
btn_func3_north.setBounds(112, 62, 36, 30);
panel_north.add(btn_func3_north);
//功能按钮4
btn_func4_north = new JButton(new ImageIcon("image/dialogimage/createteam.jpg"));
btn_func4_north.setBounds(163, 62, 36, 30);
panel_north.add(btn_func4_north);
//功能按钮5
btn_func5_north = new JButton(new ImageIcon("image/dialogimage/yuancheng.png"));
btn_func5_north.setBounds(214, 62, 36, 30);
panel_north.add(btn_func5_north);
//功能按钮6
btn_func6_north = new JButton(new ImageIcon("image/dialogimage/sharedisplay.png"));
btn_func6_north.setBounds(265, 62, 36, 30);
panel_north.add(btn_func6_north);
//功能按钮7
btn_func7_north = new JButton(new ImageIcon("image/dialogimage/yingyong.jpg"));
btn_func7_north.setBounds(318, 62, 36, 30);
panel_north.add(btn_func7_north);
//设置北部面板背景色
//panel_north.setBackground(new Color(105, 197, 239));
panel_north.setBackground(new Color(22, 154, 228));
//中部聊天内容显示部分
panel_Msg = new JTextPane();
JScrollPane scrollPane_Msg = new JScrollPane(panel_Msg);
scrollPane_Msg.setBounds(0, 92, 446, 270);
c.add(scrollPane_Msg);
//南部面板
panel_south = new JPanel();
panel_south.setBounds(0, 370, 446, 170);
panel_south.setLayout(null);
//添加南部面板
c.add(panel_south);
//内容输入区
jtp_input = new JTextPane();
jtp_input.setBounds(0, 34, 446, 105);
//添加到南部面板
panel_south.add(jtp_input);
//文本输入区上方功能按钮
//功能按钮1
btn_func1_south = new JButton(new ImageIcon("image/dialogimage/word.png"));
btn_func1_south.setBounds(10, 0, 30, 30);
panel_south.add(btn_func1_south);
//功能按钮2
btn_func2_south = new JButton(new ImageIcon("image/dialogimage/biaoqing.png"));
btn_func2_south.setBounds(47, 0, 30, 30);
panel_south.add(btn_func2_south);
//功能按钮3
btn_func3_south = new JButton(new ImageIcon("image/dialogimage/magic.jpg"));
btn_func3_south.setBounds(84, 0, 30, 30);
panel_south.add(btn_func3_south);
//功能按钮4
btn_func4_south = new JButton(new ImageIcon("image/dialogimage/zhendong.jpg"));
btn_func4_south.setBounds(121, 0, 30, 30);
panel_south.add(btn_func4_south);
//功能按钮5
btn_func5_south = new JButton(new ImageIcon("image/dialogimage/yymessage.jpg"));
btn_func5_south.setBounds(158, 0, 30, 30);
panel_south.add(btn_func5_south);
//功能按钮6
btn_func6_south = new JButton(new ImageIcon("image/dialogimage/dgninput.jpg"));
btn_func6_south.setBounds(195, 0,30, 30);
panel_south.add(btn_func6_south);
//功能按钮7
btn_func7_south = new JButton(new ImageIcon("image/dialogimage/sendimage.jpg"));
btn_func7_south.setBounds(232, 0, 30, 30);
panel_south.add(btn_func7_south);
//功能按钮8
btn_func8_south = new JButton(new ImageIcon("image/dialogimage/diange.jpg"));
btn_func8_south.setBounds(269, 0, 30, 30);
panel_south.add(btn_func8_south);
//功能按钮9
btn_func9_south = new JButton(new ImageIcon("image/dialogimage/jietu.jpg"));
btn_func9_south.setBounds(306, 0, 30, 30);
panel_south.add(btn_func9_south);
//查询聊天记录
recorde_search = new JButton(new ImageIcon("image/dialogimage/recorde.png"));
recorde_search.addActionListener(e-> {
System.out.println("点击查找聊天记录");
cardLayout.next(panel_east);
});
recorde_search.setBounds(350, 0, 96, 30);
panel_south.add(recorde_search);
//消息关闭按钮
btn_close = new JButton(new ImageIcon("image/dialogimage/close.jpg"));
btn_close
没有合适的资源?快使用搜索试试~ 我知道了~
Java+Swing+mysql仿QQ聊天工具(期末大作业).rar
共123个文件
png:40个
class:27个
jpg:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 24 浏览量
2023-12-28
17:03:53
上传
评论
收藏 2.51MB RAR 举报
温馨提示
Java+Swing+mysql仿QQ聊天工具(期末大作业)已获导师指导并通过的95分的高分期末大作业项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 系统主要实现了: 用户登陆、好友列表、好友聊天、服务器日志 详情:https://blog.csdn.net/Timi2019/article/details/124653516
资源推荐
资源详情
资源评论
收起资源包目录
Java+Swing+mysql仿QQ聊天工具(期末大作业).rar (123个子文件)
Chat.class 12KB
FriendList.class 10KB
Login.class 6KB
ServerFrame.class 6KB
Server.class 4KB
ServerConClientThread.class 4KB
LoginUser.class 3KB
JDBC_Util.class 3KB
ClientToServerThread.class 3KB
FriendList$4.class 3KB
MyTreeCellRenderer.class 2KB
ManageClientThread.class 2KB
Message.class 2KB
MsgType.class 1KB
FriendList$3.class 1KB
FriendList$2.class 1KB
Chat$1.class 1KB
Chat$2.class 1KB
ManageThread.class 1KB
Login$4.class 1KB
ManageFriendListFrame.class 1KB
Login$3.class 1KB
ManageChatFrame.class 1KB
User.class 1KB
FriendList$1.class 819B
Login$1.class 722B
Login$2.class 704B
.classpath 396B
hh.gif 212KB
qq.gif 1KB
.gitignore 184B
MyQqChat.iml 706B
mysql-connector-java-8.0.21.jar 2.29MB
Chat.java 14KB
FriendList.java 10KB
Login.java 6KB
ServerFrame.java 5KB
Server.java 4KB
ServerConClientThread.java 4KB
LoginUser.java 3KB
JDBC_Util.java 3KB
ClientToServerThread.java 2KB
MyTreeCellRenderer.java 2KB
Message.java 1KB
ManageClientThread.java 989B
User.java 670B
ManageFriendListFrame.java 632B
ManageChatFrame.java 562B
ManageThread.java 513B
MsgType.java 360B
login.jpg 9KB
Qtouxiang.jpg 3KB
jilu.jpg 2KB
send.jpg 1KB
close.jpg 1KB
tranfile.jpg 1KB
createteam.jpg 1KB
yingyong.jpg 1KB
zhendong.jpg 1016B
sendimage.jpg 962B
exit.jpg 931B
exit.jpg 931B
jietu.jpg 913B
dgninput.jpg 907B
diange.jpg 867B
yymessage.jpg 843B
min.jpg 833B
magic.jpg 809B
jiacu.jpg 804B
dmax.jpg 767B
touxiang.png 9KB
touxiang.png 9KB
huisetouxiang.png 3KB
Q.png 2KB
biaoti.png 1KB
apl.png 1KB
recorde.png 1KB
beijing.png 1KB
shipin.png 1024B
QQsearch.png 965B
tubiao9.png 961B
loginbutton.png 894B
yuyin.png 835B
biaoqing.png 805B
tubiao2.png 772B
tubiao6.png 728B
sharedisplay.png 715B
tubiao7.png 711B
tubiao1.png 686B
远程.png 664B
yuancheng.png 664B
messagemanage.png 611B
shezhi.png 611B
searchimage.png 585B
search.png 578B
word.png 533B
tubiao4.png 492B
fexit.png 481B
shoucang.png 453B
tubiao3.png 450B
共 123 条
- 1
- 2
资源评论
小码叔
- 粉丝: 5101
- 资源: 5404
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 1_ROT编码 (2).zip
- IMG_7230.jpg
- python+翻译器+语音
- 一个简单的库存管理系统,使用PHP、JavaScript、Bootstrap和CSS开发
- Python(Tkinter+matplotlib)实现光斑处理系统源代码
- HC32F4A0-v2.2.0-LittleVgl-8.3-1111.zip, 基于HC32F4A0的LVGL8.3工程
- 220913201郭博宇数据结构3.docx
- 小米R3G路由器breed专属
- MATLAB实现QRLSTM长短期记忆神经网络分位数回归时间序列区间预测(含完整的程序和代码详解)
- AN-HC32F4A0系列的外部存储器控制器EXMC -Rev1.1
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功