javase-富文本聊天工具

学完Java基础,也来写个聊天的工具,给它起了个名:GG聊天(只是希望沾点光);
功能实现如下:
(1)动态请求服务器,登录会记住用户名的
(2)好友列表显示(在线的为彩色,离线的为灰色)
(3)聊天的字体可更改(富文本编辑),查看聊天记录,
(4)注册
(5)查找用户
(6)添加在线用户(别人添加你,可以拒绝的哦)
(7)DAO模块有MySql改为XML,只要启动服务器,不需要数据库也可玩玩看;
------
带几张截图,有兴趣的可以下载下去:
[b]登录框(点击设置,可以设置服务器IP和端口):[/b][img]http://dl.iteye.com/upload/attachment/0063/7522/273d25b4-5b8c-3fef-8d12-afe6e5ac8a68.jpg[/img]
[b]注册:[/b]
[img]http://dl.iteye.com/upload/attachment/0063/7525/9e2dfbd1-b76c-3809-8771-fa171ae4aca0.jpg[/img]
[b]注册是系统自动分配一个可用数字(看完要记住de,别忘了):[/b]
[img]http://dl.iteye.com/upload/attachment/0063/7527/0a88cc08-b881-3272-a720-4ce42aa69609.jpg[/img]
[b]下面是登录后的UI(还没人上线的..):[/b][img]http://dl.iteye.com/upload/attachment/0063/7529/8a70b328-be98-3066-acc8-396f2c9b015c.jpg[/img]
[b]这是聊天的窗口(可以设置字体--还可以发送抖动窗口的):[/b]
[img]http://dl.iteye.com/upload/attachment/0063/7537/5fcdfed7-4d57-3ec2-a85b-d5930180a326.jpg[/img]
[b]查看聊天的记录:[/b][img]http://dl.iteye.com/upload/attachment/0063/7531/11bcead9-a433-32f5-99df-e476d2ca9f13.jpg[/img]
[b]好友上线啦:[/b][img]http://dl.iteye.com/upload/attachment/0063/7533/3e395203-56a1-34af-bfd0-5ed2655b3a5f.jpg[/img]
[b]可以抖他的聊天窗口的:[/b][img]http://dl.iteye.com/upload/attachment/0063/7535/77e61dfe-3290-3b26-85f5-7327aaf4d8b6.jpg[/img]
[b]查找好友的:[/b]
[img]http://dl.iteye.com/upload/attachment/0063/7539/17606686-d3d8-3966-b729-0a1f751a8597.jpg[/img]
---------------------------------
下面,奉上核心代码:
服务器的控制中心(没有采用ChannelSocket,用户太少啦,另一个版本使用那个的,有兴趣的我可以把那部分代码发给你。)
try {
while (start) {
final Message message = (Message) ois.readObject();
new Thread() {
@Override
public void run() {
String action = message.getAction();
ServerUI.setMessage("@server: " + action);
try {
ServicesCache.get(
Configuration.getClassName(action))
.execute(ServiceThread.this, oos, message);
} catch (Exception e1) {
System.err.println("catch error");
try {
Class<?> ac = Configuration.getClazz(action);
ac.getMethod("execute",
ServiceThread.class,
ObjectOutputStream.class,
Message.class).invoke(
ac.newInstance(),
ServiceThread.this, oos,
message);
} catch (Exception e) {
start = false;
e.printStackTrace();
}
}
}
}.start();
}
} catch (Exception e) {
start = false;
ServerUI.setMessage("用户断开连接!");
} finally {

}


------------------
控制中心的标准:
public abstract class ActionSupport {

private final UserDao dao = new UserDaoXMLImpl();

protected final UserDao getDao() {
return dao;
}

public abstract String execute(ServiceThread service, ObjectOutputStream oos,
Message message) throws Exception;
}

------------------
[b]哦,我忘了,还有一个可爱的系统托盘:[/b]

[img]http://dl.iteye.com/upload/attachment/0063/7541/2ff4e1b3-df8e-3a64-9723-17221caee206.jpg[/img]

[b]在附上服务器的UI:[/b]
[img]http://dl.iteye.com/upload/attachment/0063/7543/604a2a0e-ed6b-34b3-978b-7af024395a6d.jpg[/img]

下面就是源码啦,无私奉献
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值