原标题:【附源码】用Java写了一个类QQ界面聊天小项目,可在线聊天!

目录:

1.功能实现

2.模块划分

3.使用到知识

4.部分代码实现

5.运行例图

1.功能实现

1.修改功能(密码、昵称、个性签名)

2.添加好友、删除好友

3.单聊功能

4.判断好友是否在线

2.模块划分

3.使用的知识

netty

swing

集合等同步阻塞队列synchronousQueue

数据库MySQL中的CRUD

C3p0连接池

JSON字符串4.部分代码实现

1.nettyController.java

接收到来自客户端的消息,与dao层进行交互

dao层与之数据库进行交互

修改密码

添加好友

从添加好友逻辑实现上我走了很多的弯路频繁的访问数据库,这是一件很不好的事情

packagechat.Project.controller;

importchat.Project.bean.information;

importchat.Project.constant.EnMsgType;

importchat.Project.dao.*;

importchat.utils.CacheUtil;

importchat.utils.JsonUtils;

importcom.fasterxml.jackson.databind.node.ObjectNode;

importio.netty.channel.Channel;

importjava.util.ArrayList;

importjava.util.Iterator;

publicclassNettyController{

privatestaticUserDao userDao = newUserDaoImpl;

privatestaticinformationDao informationDao = newinformationDaoImpl;

privatestaticfriendDao friendDao = newfriendDaoImpl;

publicstaticString processing(String message, Channel channel){

//解析客户端发送的消息

ObjectNode jsonNodes = JsonUtils.getObjectNode(message);

String msgtype = jsonNodes.get( "msgtype").asText;

if(EnMsgType.EN_MSG_LOGIN.toString.equals(msgtype)){

//登录操作

returnloginOperation(jsonNodes,channel);

} elseif(EnMsgType.EN_MSG_MODIFY_SIGNATURE.toString.equals(msgtype)){

//修改签名

returnmodifySignature(jsonNodes);

} elseif(EnMsgType.EN_MSG_MODIFY_NICKNAME.toString.equals(msgtype)){

//修改昵称

returnmodifyNickname(jsonNodes);

} elseif(EnMsgType.EN_MSG_GETINFORMATION.toString.equals(msgtype)){

//获取登录信息

returngetInformation(jsonNodes);

} elseif(EnMsgType.EN_MSG_VERIFY_PASSWORD.toString.equals(msgtype)){

//进行修改密码

returnverifyPasswd(jsonNodes);

} elseif(EnMsgType.EN_MSG_CHAT.toString.equals(msgtype)){

//单聊模式

returnSingleChat(jsonNodes);

} elseif(EnMsgType.EN_MSG_GET_ID.toString.equals(msgtype)){

//获取id

returngetId(jsonNodes);

} elseif(EnMsgType.EN_MSG_GET_FRIEND.toString.equals(msgtype)){

//获取好友列表

returngetFriend(jsonNodes);

} elseif(EnMsgType.EN_MSG_ADD_FRIEND.toString.equals(msgtype)){

//添加好友

returnaddFriends(jsonNodes);

} elseif(EnMsgType.EN_MSG_DEL_FRIEND.toString.equals(msgtype)){

//删除好友

returndelFriend(jsonNodes);

} elseif(EnMsgType.EN_MSG_ACTIVE_STATE.toString.equals(msgtype)){

//判断好友的在线状态

returnfriendIsActive(jsonNodes);

}

return"";

}

//判断好友在线状态

privatestaticString friendIsActive(ObjectNode jsonNodes){

intfriendId = jsonNodes.get( "friendId").asInt;

ObjectNode objectNode = JsonUtils.getObjectNode;

objectNode.put( "msgtype",EnMsgType.EN_MSG_ACK.toString);

objectNode.put( "srctype",EnMsgType.EN_MSG_ACTIVE_STATE.toString);

//客户端保证用户独立存在且是好友

Channel channel = CacheUtil.get(friendId);

//判断用户是否在线

if(channel == null){

//用户不在线

objectNode.put( "code", 200);

} else{

//用户在线

objectNode.put( "code", 300);

}

returnobjectNode.toString;

}

//添加好友

privatestaticString delFriend(ObjectNode jsonNodes){

Integer friendId = jsonNodes.get( "friendId").asInt;

intuserId = jsonNodes.get( "id").asInt;

String localName = jsonNodes.get( "localName").asText;

//封装发回客户端的JSON

ObjectNode objectNode = JsonUtils.getObjectNode;

objectNode.put( "msgtype",EnMsgType.EN_MSG_ACK.toString);

objectNode.put( "srctype",EnMsgType.EN_MSG_DEL_FRIEND.toString);

objectNode.put( "code", 200);

//验证是否存在当前好友

information information = informationDao.getInformation(friendId);

String friendName = information.getNickname;

//查询自己是否有该好友

booleanexist = friendDao.isExist(friendName,userId);

if(exist){

//存在当前好友进行删除操作

friendDao.delFriend(userId,friendName);

friendDao.delFriend(friendId,localName);

objectNode.put( "code", 300);

}

returnobjectNode.toString;

}

//添加好友

privatestaticString addFriends(ObjectNode jsonNodes){

Integer friendId = jsonNodes.get( "friendId").asInt;

intuserId = jsonNodes.get( "id").asInt;

String localName = jsonNodes.get( "localName").asText;

//验证是否有ID

booleanexists = userDao.verifyExistFriend(friendId);

ObjectNode objectNode = JsonUtils.getObjectNode;

objectNode.put( "msgtype",EnMsgType.EN_MSG_ACK.toString);

objectNode.put( "srctype",EnMsgType.EN_MSG_ADD_FRIEND.toString);

objectNode.put( "code", 200);

if(exists){

//表示存在此id

objectNode.put( "code", 300);

//获取好友昵称

information information = informationDao.getInformation(friendId);

String friendNickname = information.getNickname;

//进行添加好友的操作 两个对应的信息都应该添加

friendDao.addFriends(userId,localName,friendNickname);

friendDao.addFriends(friendId,friendNickname,localName);

}

returnobjectNode.toString;

}

//获取好友列表

privatestaticString getFriend(ObjectNode jsonNodes){

intuid = jsonNodes.get( "uid").asInt;

//返回ArrayLis集合

ArrayList friends = friendDao.getFriends(uid);

//封装JSON

ObjectNode objectNode = JsonUtils.getObjectNode;

objectNode.put( "msgtype",EnMsgType.EN_MSG_ACK.toString);

objectNode.put( "srctype",EnMsgType.EN_MSG_GET_FRIEND.toString);

//写回friend集合

Iterator iterator = friends.iterator;

inti = 0;

while(iterator.hasNext){

objectNode.put( "res"+i,iterator.next);

i++;

}

//记录好友个数

objectNode.put( "count",i);

returnobjectNode.toString;

}

//获取id

privatestaticString getId(ObjectNode jsonNodes){

String nickname = jsonNodes.get( "nickname").asText;

information information = informationDao.nicknameGetId(nickname);

//联系人的id

intuid = information.getUid;

//封装JSON

ObjectNode objectNode = JsonUtils.getObjectNode;

objectNode.put( "msgtype",EnMsgType.EN_MSG_ACK.toString);

objectNode.put( "srctype",EnMsgType.EN_MSG_GET_ID.toString);

objectNode.put( "uid",uid);

returnobjectNode.toString;

}

//单聊模式

privatestaticString SingleChat(ObjectNode jsonNodes){

intid = jsonNodes.get( "id").asInt;

//根据id在friend表获取登录用户名

//封装JSON数据服务端转发数据

ObjectNode objectNode = JsonUtils.getObjectNode;

objectNode.put( "msgtype",EnMsgType.EN_MSG_ACK.toString);

objectNode.put( "srctype",EnMsgType.EN_MSG_CHAT.toString);

//客户端保证用户独立存在且是好友

Channel channel = CacheUtil.get(id);

//判断用户是否在线

if(channel == null){

//用户不在线

objectNode.put( "code", 200);

} else{

//用户在线

objectNode.put( "code", 300);

//消息转发

channel.writeAndFlush(jsonNodes.toString);

}

returnobjectNode.toString;

}

//修改密码

privatestaticString verifyPasswd(ObjectNode jsonNodes){

intid = jsonNodes.get( "id").asInt;

String oldPasswd = jsonNodes.get( "oldPasswd").asText;

String newPasswd = jsonNodes.get( "newPasswd").asText;

booleanexits = userDao.verifyPassword(oldPasswd, id);

ObjectNode objectNode = JsonUtils.getObjectNode;

objectNode.put( "msgtype",EnMsgType.EN_MSG_VERIFY_PASSWORD.toString);

objectNode.put( "code", 200);

if(exits){

//验证成功

userDao.modifyPasswd(newPasswd,id);

objectNode.put( "code", 300);

}

returnobjectNode.toString;

}

//获取信息

privatestaticString getInformation(ObjectNode jsonNodes){

intid = jsonNodes.get( "id").asInt;

information information = informationDao.getInformation(id);

//封装JSON发回客户端

ObjectNode objectNode = JsonUtils.getObjectNode;

objectNode.put( "msgtype",EnMsgType.EN_MSG_ACK.toString);

objectNode.put( "srctype",EnMsgType.EN_MSG_GETINFORMATION.toString);

objectNode.put( "Nickname",information.getNickname);

objectNode.put( "Signature",information.getSignature);

returnobjectNode.toString;

}

//修改昵称

privatestaticString modifyNickname(ObjectNode jsonNodes){

intid = jsonNodes.get( "id").asInt;

String nickname = jsonNodes.get( "nickname").asText;

//进行存储

informationDao.storeNickname(nickname,id);

return"";

}

//修改签名

privatestaticString modifySignature(ObjectNode jsonNodes){

intid = jsonNodes.get( "id").asInt;

String signature = jsonNodes.get( "signature").asText;

//进行存储

informationDao.storeSignature(signature,id);

return"";

}

//登录操作

privatestaticString loginOperation(ObjectNode objectNode,Channel channel){

intid = objectNode.get( "id").asInt;

String passwd = objectNode.get( "passwd").asText;

//进行数据库查询

booleanexits = userDao.getInformation(id, passwd);

ObjectNode jsonNodes = JsonUtils.getObjectNode;

jsonNodes.put( "msgtype",EnMsgType.EN_MSG_ACK.toString);

jsonNodes.put( "srctype",EnMsgType.EN_MSG_LOGIN.toString);

jsonNodes.put( "code", 300);

//返回状态码

if(exits){

jsonNodes.put( "code", 200);

//添加用户的在线信息

CacheUtil.put(id,channel);

}

returnjsonNodes.toString;

}

}

2.ClientHandler.java

客户端接受来自服务端返回的消息

根据返回的状态码来判断是否操作成功

packagechat.Project.netty;

importchat.Frame.chat.ChatFrame;

importchat.Frame.chat.linkmen;

importchat.Frame.chat.login;

importchat.Project.constant.EnMsgType;

importchat.util.JsonUtils;

importcom.fasterxml.jackson.databind.node.ObjectNode;

importio.netty.channel.ChannelHandlerContext;

importio.netty.channel.SimpleChannelInboundHandler;

importjava.util.concurrent.SynchronousQueue;

publicclassClientHandlerextendsSimpleChannelInboundHandler< String>{

//定义一个同步阻塞队列状态码

publicstaticSynchronousQueue queue = newSynchronousQueue<>;

publicstaticString Nickname;

publicString Signature;

@Override

protectedvoidchannelRead0(ChannelHandlerContext channelHandlerContext, String s)throwsException{

}

//客户端接收数据

@Override

publicvoidchannelRead(ChannelHandlerContext ctx, Object msg)throwsException{

System.out.println(msg);

//解析服务端发送的消息

ObjectNode jsonNodes = JsonUtils.getObjectNode((String) msg);

String msgtype = jsonNodes.get( "msgtype").asText;

if(EnMsgType.EN_MSG_ACK.toString.equals(msgtype)) {

String srctype = jsonNodes.get( "srctype").asText;

if(EnMsgType.EN_MSG_LOGIN.toString.equals(srctype)) {

//登录操作

queue.offer(jsonNodes.get( "code").asInt);

} elseif(EnMsgType.EN_MSG_GETINFORMATION.toString.equals(srctype)){

//存取信息

Nickname = jsonNodes.get( "Nickname").asText;

Signature = jsonNodes.get( "Signature").asText;

linkmen.label_1.setText(Nickname);

linkmen.field.setText(Signature);

} elseif(EnMsgType.EN_MSG_CHAT.toString.equals(srctype)){

//发送端返回消息

queue.offer(jsonNodes.get( "code").asInt);

} elseif(EnMsgType.EN_MSG_GET_ID.toString.equals(srctype)){

intuid = jsonNodes.get( "uid").asInt;

queue.offer(uid);

} elseif(EnMsgType.EN_MSG_GET_FRIEND.toString.equals(srctype)){

//获取登录用户的好友

intcount = jsonNodes.get( "count").asInt;

login.friend = newString[count];

for( inti = 0;i

login.friend[i] = jsonNodes.get( "res"+i).asText;

System.out.println(jsonNodes.get( "res"+i));

}

} elseif(EnMsgType.EN_MSG_ADD_FRIEND.toString.equals(srctype)){

//添加好友

queue.offer(jsonNodes.get( "code").asInt);

} elseif(EnMsgType.EN_MSG_DEL_FRIEND.toString.equals(srctype)){

//删除好友

queue.offer(jsonNodes.get( "code").asInt);

} elseif(EnMsgType.EN_MSG_ACTIVE_STATE.toString.equals(srctype)){

//好友在线状态

queue.offer(jsonNodes.get( "code").asInt);

}

} elseif(EnMsgType.EN_MSG_VERIFY_PASSWORD.toString.equals(msgtype)){

//修改密码

intcode = 0;

code = jsonNodes.get( "code").asInt;

queue.offer(code);

} elseif(EnMsgType.EN_MSG_CHAT.toString.equals(msgtype)){

//接收端接受消息 封装朋友昵称

String message = " "+ jsonNodes.get( "message").asText;

//聊天显示框读取消息

ChatFrame.sb.append(message+ "n");

ChatFrame.displayTextPanel.setText(ChatFrame.sb.toString);

}

}

}

3.linkmen.java

这是登录成功的界面

packagechat.Frame.chat;

importchat.Frame.operation.alterColumn.changeNickname;

importchat.Frame.operation.alterColumn.changePassword;

importchat.Frame.operation.alterColumn.changeSignature;

importchat.Frame.operation.friendHandle.addFriend;

importchat.Frame.operation.friendHandle.delFriend;

importchat.Frame.tipFrame;

importchat.Project.services.sendServers;

importio.netty.channel.Channel;

importjavax.swing.*;

importjavax.swing.event.ListSelectionEvent;

importjavax.swing.event.ListSelectionListener;

importjava.awt.*;

importjava.awt.event.ItemEvent;

importjava.awt.event.ItemListener;

/**

* 联系人界面

*/

publicclasslinkmenextendsJFrame{

//容器

privateJFrame frame;

//标签

privateJLabel label_2, label_3, label_4, label;

//昵称

publicstaticJLabel label_1;

//状态框

privateJComboBox box, box_1, box_2;

//图片

privateImageIcon icon_1, icon;

//文本

privateJTextField field_1;

//个性签名

publicstaticJTextField field;

//面板

privateJPanel panel_1, panel_3, panel;

//滚动面板

publicJScrollPane panel_2;

//列表

publicstaticJList list;

//与服务端通信的通道

privateChannel channel;

//用户的id

privateInteger id;

//暂存oldPasswd

publicstaticJLabel label_5,label_6;

//好友列表数组

privateString[] fd;

//列表

publicstaticDefaultListModel model;

publiclinkmen(Integer id, Channel channel,String[] fd){

this.id = id;

this.channel = channel;

this.fd = fd;

}

publicvoidinit{

//初始化面板1并设置信息

panel_1 = newJPanel;

panel_1.setLayout( null);

panel_1.setLocation( 0, 0);

panel_1.setBorder(BorderFactory.createTitledBorder( "资料卡"));

panel_1.setSize( newDimension( 295, 148));

panel_1.setOpaque( false);

//初始化面板3并设置信息

panel_3 = newJPanel;

panel_3.setLayout( null);

panel_3.setBorder(BorderFactory.createTitledBorder( "系统设置"));

panel_3.setLocation( 0, 617);

panel_3.setSize( newDimension( 295, 55));

panel_3.setOpaque( false);

//设置头像标签

label_2 = newJLabel( newImageIcon( "E:聊天软件untitledsrcimageSource4.png"));

label_2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

label_2.setBounds( 15, 15, 100, 100);

panel_1.add(label_2);

//初始暂存标签

label_5 = newJLabel;

label_6 = newJLabel;

//设置昵称标签

label_1 = newJLabel( "");

label_1.setBounds( 130, 10, 100, 30);

label_1.setFont( newFont( "宋体", Font.PLAIN, 18));

panel_1.add(label_1);

list = newJList(model);

//设置每个列表的高

list.setFixedCellHeight( 20);

list.setSelectionBackground( newColor( 0xD8FF2F));

list.addListSelectionListener( newListSelectionListener {

@Override

publicvoidvalueChanged(ListSelectionEvent e){

//打开一个聊天窗口

if(e.getValueIsAdjusting) {

for( inti = 0; i < model.size; i++) {

if(model.get(i).equals(list.getSelectedValue)){

//获取id有错误

intids = newsendServers(channel).getId((String) list.getSelectedValue);

if(ids!= 0) {

newsendServers(channel).friendIsActive(ids);

newChatFrame(ids, channel).setVisible( true);

} else{

System.out.println( "好友不存在");

}

}

}

}

}

});

//初始化面板二

panel_2 = newJScrollPane(list);

panel_2.setBorder(BorderFactory.createTitledBorder( "联系人"));

panel_2.setLocation( 0, 147);

panel_2.setSize( newDimension( 295, 470));

panel_2.getViewport.setOpaque( false);

list.setOpaque( false);

panel_2.setOpaque( false);

//设置在线状态bBox;

box = newJComboBox;

box.addItem( "✅在线");

box.addItem( "uD83DuDCBF隐身");

box.addItem( "uD83DuDCBB忙碌");

box.addItem( "❎离线");

box.setBounds( 200, 10, 70, 30);

panel_1.add(box);

//设置个性签名的标签

label_4 = newJLabel( "个性签名:");

label_4.setFont( newFont( "宋体", Font.PLAIN, 16));

label_4.setForeground(Color.BLUE);

label_4.setBounds( 120, 50, 100, 20);

panel_1.add(label_4);

//设置文本

field = newJTextField( "");

field.setBounds( 120, 80, 160, 30);

panel_1.add(field);

label_3 = newJLabel( "uD83DuDD0D");

label_3.setForeground(Color.RED);

label_3.setBounds( 10, 122, 20, 20);

panel_1.add(label_3);

//设置搜索栏

field_1 = newJTextField;

field_1.setBounds( 30, 120, 250, 25);

panel_1.add(field_1);

//对面板三进行初始化

box_1 = newJComboBox;

box_1.addItem( "uD83DuDD12uD83DuDD28uD83DuDD13");

box_1.addItem( "修改密码");

box_1.addItem( "修改昵称");

box_1.addItem( "修改签名");

box_1.setBounds( 8, 20, 100, 25);

panel_3.add(box_1);

box_1.addItemListener( newItemListener {

@Override

publicvoiditemStateChanged(ItemEvent e){

if( "修改签名".equals(box_1.getSelectedItem)) {

//执行一次

if(e.getStateChange == ItemEvent.SELECTED) {

changeSignature changeSignature = newchangeSignature(linkmen. this);

changeSignature.setVisible( true);

field.setText(changeSignature.jTextField.getText);

String signature = field.getText;

//存储签名的方法

newsendServers(channel).modifySignature(signature, id);

}

}

if( "修改密码".equals(box_1.getSelectedItem)) {

if(e.getStateChange == ItemEvent.SELECTED) {

changePassword changePassword = newchangePassword(linkmen. this);

changePassword.setVisible( true);

label_5.setText(changePassword.oldPassword.getText);

String oldPasswd = label_5.getText;

label_6.setText( newString(changePassword.newPassword.getPassword));

String newPasswd = label_6.getText;

//进行验证

newsendServers(channel).verifyPasswd(oldPasswd, id,newPasswd);

}

}

if( "修改昵称".equals(box_1.getSelectedItem)) {

if(e.getStateChange == ItemEvent.SELECTED) {

changeNickname changeNickname = newchangeNickname(linkmen. this);

changeNickname.setVisible( true);

label_1.setText(changeNickname.jTextField.getText);

String nickname = label_1.getText;

//存储昵称

newsendServers(channel).modifyNickname(nickname, id);

}

}

}

});

//添加好友、删除好友

box_2 = newJComboBox;

box_2.addItem( "uD83DuDC65");

box_2.addItem( "添加好友");

box_2.addItem( "删除好友");

box_2.setBounds( 170, 20, 100, 25);

box_2.addItemListener( newItemListener {

@Override

publicvoiditemStateChanged(ItemEvent e){

if( "添加好友".equals(box_2.getSelectedItem)) {

if(e.getStateChange == ItemEvent.SELECTED) {

addFriend addFriend = newaddFriend(linkmen. this);

addFriend.setVisible( true);

//读取要搜索的ID

String friendIds = addFriend.jTextField.getText;

//判断是否是字符串

if(judgeDigit(friendIds)){

intfriendId = Integer.parseInt(friendIds);

//搜索数据库

newsendServers(channel).addFriendOperate(friendId,id,label_1.getText);

} else{

newtipFrame.init( "输入参数错误");

}

}

}

if( "删除好友".equals(box_2.getSelectedItem)) {

if(e.getStateChange == ItemEvent.SELECTED) {

delFriend delFriend = newdelFriend(linkmen. this);

delFriend.setVisible( true);

//对其数据库进行删除操作

String friendIds = delFriend.TextField.getText;

//判断是否是字符串

if(judgeDigit(friendIds)){

intfriendId = Integer.parseInt(friendIds);

//操作数据库

newsendServers(channel).delFriendOperate(friendId,id,label_1.getText);

} else{

newtipFrame.init( "输入参数错误");

}

}

}

}

});

panel_3.add(box_2);

//设置frame信息

frame = newJFrame;

//设置窗体信息

frame.setTitle( "腾讯QQ");

//给窗体设置图片

icon_1 = newImageIcon( "E:聊天软件untitledsrcimageSource3.png");

frame.setIconImage(icon_1.getImage);

icon = newImageIcon( "E:聊天软件untitledsrcimageSource5.png");

label = newJLabel(icon);

//获取窗口的第二层,将label放入

frame.getLayeredPane.add(label, newInteger(Integer.MIN_VALUE));

//获取frame的顶层容器,并设置为透明

panel = (JPanel) frame.getContentPane;

panel.setOpaque( false);

frame.setLayout( null);

frame.setLocation( 750, 150);

frame.setSize( 287, 700);

frame.setVisible( true);

frame.setResizable( false);

label.setBounds( 0, 0, 287, 700);

frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

frame.add(panel_1);

frame.add(panel_2);

frame.add(panel_3);

}

publicvoidmian{

//初始化面板2并设置信息

model = newDefaultListModel<>;

for( inti = 0; i < fd.length; i++) {

model.addElement(fd[i]);

}

init;

//更新昵称和签名

newsendServers(channel).update(id);

//获取用户的昵称,和好友列表

//设置签名和昵称字体初始样式和大小

label_1.setFont( newFont( "宋体", Font.PLAIN, 18));

field.setFont( newFont( "宋体", Font.PLAIN, 18));

}

//判断是否是数字

privatestaticbooleanjudgeDigit(String string){

for( inti = 0; i < string.length; i++) {

if(!Character.isDigit(string.charAt(i))){

returnfalse;

}

}

returntrue;

}

}

4.tipFrame

提示操作状态窗口

packagechat.Frame;

importchat.Frame.chat.linkmen;

importchat.Frame.operation.alterColumn.changeNickname;

importjavax.swing.*;

importjava.awt.*;

importjava.awt.event.ActionEvent;

importjava.awt.event.ActionListener;

publicclasstipFrameextendsJDialog{

privateContainer container;

//显示错误信息

publicJLabel label;

//确认按钮

privateJButton button;

publictipFrame{

}

publicvoidinit(String msg){

container = getContentPane;

label = newJLabel(msg);

label.setBounds( 70, 0, 200, 70);

label.setFont( newFont( "微软雅黑",Font.PLAIN, 20));

container.add(label);

button = newJButton( "确认");

button.setBounds( 35, 50, 140, 40);

container.add(button);

setBounds( 780, 170, 220, 140);

setLayout( null);

setVisible( true);

container.setBackground( newColor( 0xD8FFD5));

//提示窗口前置

setAlwaysOnTop( true);

button.addActionListener( newActionListener {

@Override

publicvoidactionPerformed(ActionEvent e){

tipFrame. this.dispose;

}

});

}

}

5.运行例图

1.登录界面

注册账号和忘记密码没有添加事件现在就是个摆设

2.联系人界面

这里面的所有功能都可以使用

3.聊天界面

这个里面表情按钮没弄好

4.通信的过程

5.修改操作

6.好友的操作

责任编辑:

java qq聊天界面_【附源码】用Java写了一个类QQ界面聊天小项目,可在线聊天!...相关推荐

  1. java 包装类方法总结_【源码】java包装类总结

    1.包装类除了Void和Character,其他六个全部都继承自Number.Number是一个抽象类.如下: public abstract class Number implements java ...

  2. 天天酷跑php源码_使用Java实现天天酷跑(附源码)

    首先,写一个需求文档: 一.项目名称:<天天酷跑>(RunDay) 二.功能介绍: 闯关类游戏,玩家登录后,选择进入游戏,通过键盘控制玩家的上下左右移动,来躲避 障碍物和吃金币,玩家躲避的 ...

  3. 手把手搭建Java金融借贷系统【附源码】(毕设)

    一.项目简介 本课程演示的是一套基于基于JavaWeb实现的金融借贷系统 或 P2P金融管理系统 或 小额贷款系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群. 详细介绍 ...

  4. 视频教程-手把手实现Java图书管理系统(附源码)-Java

    手把手实现Java图书管理系统(附源码) 南京大学软件工程硕士,曾就职于擎天科技.中软国际.华为等上市公司,擅长Java开发.Web前端.Python爬虫.大数据等领域技术. 全栈工程师,从事软件开发 ...

  5. 视频教程-手把手搭建Java金融借贷系统【附源码】(毕设)-Java

    手把手搭建Java金融借贷系统[附源码](毕设) 南京大学软件工程硕士,全栈开发工程师,全栈讲师. 曾就职于中软国际.擎天科技.华为等公司,擅长Java开发.Web前端.Python爬虫.PHP等领域 ...

  6. 安卓登录注册界面开发(附源码)

    源码下载和博客访问:安卓登录注册界面开发(附源码) 前言 最近找安卓登录注册界面,找了好久也没找到比较满意的设计,最后想想其实登录和注册两个界面也不复杂,干脆花点时间自己弄. 界面预览 最后的效果如下 ...

  7. java手机象棋软件下载,Java手机网络版象棋游戏附源码JAVA游戏源码下载

    运行于手机上的中国象棋游戏,鉴于JAVA J2ME技术,本游戏分服务端和客户端,导入JAR包即可在手机上运行,内有开发文档和运用说明. Java手机网络版象棋游戏附源码 (1 folders, 2 f ...

  8. JAVA计算机毕业设计摄影网站(附源码、数据库)

    JAVA计算机毕业设计摄影网站(附源码.数据库) 目运行 环境项配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(Inte ...

  9. [附源码]计算机毕业设计Python+uniapp晋中市居民健康卡小程序j7d04(程序+lw+远程部署)

    [附源码]计算机毕业设计Python+uniapp晋中市居民健康卡小程序j7d04(程序+lw+远程部署) 该项目含有源码.文档.程序.数据库.配套开发软件.软件安装教程 项目运行环境配置: Pyth ...

最新文章

  1. Android Q 变更和新特性
  2. Android教程之android数据库编程
  3. 报告预测:到2027年,全球数据中心基础设施市场规模将达1423.1亿美元
  4. 用计算机计算性别,2018预测生男生女计算器 超准的怀孕计算器查生男生女
  5. Panorama Viewer – jQuery 360度全景展示插件
  6. HDU 3328 Flipper 栈 模拟
  7. Oracle 权限管理
  8. 深度学习实现缺陷检测算法汇总
  9. 共享单车信息系统服务器部署,共享单车云服务器搭建
  10. ETCD数据库源码分析——ProgressTracker
  11. 还不了解,日志框架吗?
  12. 《自控力》第九章读书笔记
  13. python 字符串结束符_python字符串以反斜杠结尾
  14. plotly绘制简单图形<7>--用plotly画图参数设置
  15. 虚拟团队四大管理技巧
  16. 人脸检测与美颜技术介绍(OpenCV)
  17. Mybatis plus 之 QueryWrapper、LambdaQueryWrapper、LambdaQueryChainWrapper
  18. 计算中英文混合字符串长度
  19. 【C语言进阶】指针 下
  20. git设置当前项目的用户名称name和邮箱email

热门文章

  1. python--Flask学习(七)--利用Flask中的werkzeug.security模块加密
  2. vue里 a(){} 和a:()=>{}的区别
  3. PDF怎么压缩到最小?有在线压缩的方法吗
  4. pdf压缩文件怎么压缩最小,pdf大小超过上传大小不能上传怎么压缩?
  5. KEIL设置程序起始地址无效解决方法,STM32 IAP程序起始地址
  6. android 5.0合并分区,中兴天极2 S291合并分区刷Android 5.1刷机教程
  7. 基于科大讯飞语音识别demo(离线)
  8. 在线通过dd命令备份分区
  9. 追捧《弟子规》,因为你并不知道古代的优质教育是什么
  10. 新颖的自我介绍_简单新颖的自我介绍范文