飞鸽传书(java版)源代码
- 格式:doc
- 大小:265.50 KB
- 文档页数:89
目录1 绪论 (1)1.1本程序的开发背景 (1)1.2开发环境 (1)1.3 Java语言 (1)1.4 关于Eclipse (2)2 程序结构和设计思想 (4)2.1本文解决的主要技术问题 (4)2.2程序设计结构 (4)2.3程序设计思想 (5)3 程序分析和具体实现 (7)3.1目录选择器 (7)3.2重要图形界面模块的实现 (10)3.3任务栏托盘图标和任务栏弹出对话框 (17)3.4信息收发和文件传输的实现 (21)3.5使用外部程序包 (28)3.6发布程序 (33)1 绪论1.1 本软件的开发背景当今,是一个信息高度发达的时代,计算机无疑已经成为网络通信的主角,生活节奏的加快,使得人们对通信速度的要求越来越高。
对于在局域网内的计算机之间的数据交互,尤其是文件传输,通常,人们习惯于通过借助于移动存储介质,采取重复拷贝的方式来实现。
这种传统文件传输方式存在诸多缺点,比如:1.消耗时间长,反复拔插存储介质过程繁琐;2.文件交互频繁,加速了计算机病毒的传播;3.虽然可以通过操作系统实现在局域网内的数据共享,但终因操作困难而使人们望而却步。
在如此多困难之下,人们不禁会考虑,能不能通过软件来实现计算机之间的数据交互?答案是肯定的。
本程序将针对这些问题进行设计。
1.2 开发环境操作系统:Microsoft Windows XP程序语言:Java 2开发包:Java(TM) 2 Standard Edition (6.0)开发平台:Eclipse 3.0+Swing Designer+JRE6.01.3 Java语言Java平台演进到Java2后,分别针对不同领域的需求被分成三个版本,亦即J2EE、J2SE、J2ME。
本程序使用J2SE。
J2SE是Java的标准版本 (Java2 Standard Edition),定位在客户端,主要用于桌面应用软件的编程。
J2SE 包含那些构成Java语言核心类库。
发送文件目录主函数是SendDirFile(SendFileObj*obj)该函数里面有五个分支判断分别对应的属性(即发送状态是)FS_OPENINFO FS_FIRSTINFO||FS_NEXTINFO FS_DIRFILESTART||FS_MAKEI NFO FS_TRANSINFO FS_TRANSFILE各自做不同处理在上一分支做了处理后即将属性改为下一属性,等到下一分支处理。
在FS_OPENINFO里面在FS_FIRSTINFO||FS_NEXTINFO里面如果是FS-FIRSTINFO属性,给发送对象的path 添加”* “任意文件,避过开始在该目录下寻找第一个文件如果为FS_NEXTINFO属性则用FindNextFile向后循环查找目录下其他文件,这个函数第二个参数都是WIN32_FIND_DATA然后开始在后面while循环查找所有(非目录的)文件,如果查找到第一个非目录即非.或者..的文件,将属性改为FS_MAKEINFO在FS_DIRFILESTART||FS_MAKEINFO属性里面构造与该文件有关的一切属性,比如路径目录属性等等,构造好以后改属性为FS_TRANSINFO在FS_TRANSINFO属性里面发送文件相关的属性比如目录路径属性如果没有发送完毕,继续发送, obj->status = obj->dirCnt < 0 ? FS_COMPLETE : find == FALSE ?FS_NEXTINFO : (obj->fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ?FS_OPENINFO : FS_TRANSFILE;根据这条代码进行判断此时发送对象状态,设置不同属性,如果dircnt目录数目小于0,发送完毕,设置为FS_COMPLETE,否则根据find属性判断是设置FS_NEXTINFO继续查找文件,如果查找完毕根据属性是否为目录是的话回到开始设置FS_OPENINFO属性,查找下一层目录,都完毕了,设置FS_TRANSFILE开始真正的文件传送在FS_TRANSFILE里面开始真正的文件传送(实际上是调用SendFile函数发送),发送完后关闭发送函数,然后根据文件的状态,目录与否修改属性为FS_NEXTINFO或FS_MAKEINFO继续发送。
Java物流管理系统源代码简介物流管理系统是一种基于Java开发的应用程序,用于管理货物的运输和配送过程。
该系统通过集成不同的功能模块,提供了全面的物流管理解决方案。
本文档旨在介绍物流管理系统的源代码结构和实现细节。
源代码结构物流管理系统的源代码包含多个主要模块,每个模块负责不同的功能。
以下是系统的主要模块:1.用户模块:负责管理用户的注册、登录和权限管理。
2.仓库模块:用于管理仓库的信息,包括仓库位置、库存和货物的入库和出库。
3.运输模块:负责管理货物的运输过程,包括路线规划、运输订单的生成和司机的分配。
4.订单模块:用于管理客户订单的生成、处理和物流跟踪。
5.报表模块:负责生成物流管理系统的各种报表和统计数据。
实现细节技术选型物流管理系统使用Java作为主要开发语言,并使用以下技术和框架来实现各个模块:•Spring框架:用于实现系统的核心业务逻辑和管理对象的依赖关系。
•Spring MVC:用于实现系统的Web接口和处理用户请求。
•MyBatis:用于与数据库进行交互,包括查询、插入、更新和删除数据。
•MySQL数据库:用于存储系统的数据。
•HTML、CSS和JavaScript:用于实现系统的前端界面和用户交互。
•Bootstrap框架:用于快速构建响应式布局和美观的前端界面。
数据库设计物流管理系统的数据库包含多个表,每个表存储不同类型的数据。
以下是系统的主要数据库表:1.用户表:存储用户的登录信息和权限设置。
2.仓库表:存储仓库的基本信息,包括名称、位置和库存状况。
3.货物表:存储货物的详细信息,包括名称、数量和价格。
4.运输表:存储运输订单的信息,包括起始地点、目的地和预计送达时间。
5.订单表:存储客户订单的详细信息,包括订单号、货物、数量和收货地址。
功能实现物流管理系统提供了以下主要功能:1.用户注册和登录:用户可以通过注册新账户并登录系统,以便使用系统的各项功能。
2.仓库管理:管理员可以添加、删除和修改仓库的信息,并查看当前的库存状况。
目录飞鸽传书主界面ipmsg全称:IP Messenger,中文名为“飞鸽传书”,是一款由一个名叫H.Shirouzu的日本人开发和维护的用C语言写的局域网聊天和文件传输工具。
后来发展为很多志愿者共同开发多种版本。
它是一个小巧方便的即时通信软件,它适合用于局域网内甚至广域网间进行实时通信和文档共享。
特别是在局域网内传送文件/文件夹的效率很高。
它具有很多优点,如数据通讯不需要建立服务器、直接在两台电脑间通信和数据传输,支持文件及文件目录的传输,安全快捷以及小巧方便等优异特点,因此很多公司都采用它作为部门、公司内部的IM 即时通信工具。
Ipmsg - 功能介绍- IPMsg 是一款局域网内即时通信软件, 基于TCP/IP(UDP).可运行于多种操作平台(Win/Mac/UNIX/Java), 并实现跨平台信息交流.- 不需要服务器支持(软件本身集成了服务端和客户端)- 支持文件/文件夹的传送(2.00版以上)- 通讯数据采用RSA/Blofish 加密(2.00版以上)- 十分小巧, 简单易用, 而且可以完全免费使用它- 目前已有的版本包括: Win32, Win16, MacOS, MacOSX, X11, GTK, GNOME,Java 等,并且公开源代码。
Ipmsg - 源码简介IP Messenger在程序结构方面采用了Windows SDK处理结构,通信方面采用了TCP/UDP通信方式,在文件传输处理方面采用文件映射技术,等等。
通过分析IP Messenger 的运行、工作原理,可以提高并加深对Windows处理流程的理解,提高SOCKET编程技术等,因此特对其源码进行分析,以抛砖引玉,共同提高大家的编程技术。
1、IP Messenger源代码的下载在写这篇文章时,IP Messenger的最新版本是2.06,因此大家在下载时尽量选择最新版本下载。
IP Messenger源代码的下载地址是/,在网站的右上角,点击English page,网站转换到英文界面,网站有英文版以及其它语言的版本,当然还有中文版的链接(/IPMsg/),建议大家尽量下载原版的英文版源代码,以利于学习。
毕业论文(设计)题目基于Java的局域网飞鸽传书软件设计与实现系部计算机科学与工程系专业计算机科学与技术年级 2009学生姓名学号指导教师基于Java的局域网飞鸽传书软件设计与实现计算机科学与技术学生指导教师【摘要】随着移动互联网的时代已经来临,社交应用广泛存在,这些应用加强了人与人之间的沟通;从小环境来说比如校园网,以及部分局域网在内的的各种交互也广泛存在。
局域网之间的信息交互,并不一定要建立在互联网的基础上,本设计就是针对局域网这一环境,旨在通过设计基于Java程序设计语言的一个局域网内能够相互通信,和传输文件的软件,来增强自我实践能力,及了解通信软件的设计技术。
本设计是用Java语言编写的类飞鸽传书软件,可以实现简单的局域网内的主机之间的信息发送,以及文件的传输,实现较简单快速,主要采用了UDP中的数据报协议,Socket 协议实现主机之间的通信。
【关键词】局域网通信传输文件IP Messenger-software design and implementation used in LANbased on Java【Abstract】As the age of mobile and Internet is coming , social applications is widespread, and these applications enhance communication between people at the same time; On the side from the environment, such as campus network, as well as the various interactions, including the part of the LAN is also widespread. Internet for information exchange between the LAN is not necessary, this design is for the local area network designed to communicate with each other within a local area network based on the Java programming language through this design, and transfer files software to enhance the ability of self-practice,and understanding of communications software design techniques.The design,which included in the IP Messenger software is written in Java , can send information and make file transfers between the host. It is simple and fast, mainly uses the Matagorda Protocol UDP, Socket protocol communication between hosts.【Keywords】LAN,Communication, transmission File目录第一章绪论 (5)1.1研究现状 (5)1.2主要研究内容 (5)1.3论文结构 (6)第二章需求分析及技术介绍 (7)2.1软件运行环境及开发环境 (7)2.1.1开发环境配置 (7)2.2相关技术介绍 (10)2.2.1Eclipse开发工具的选择原因 (10)2.2.2Java介绍 (10)2.2.3 Java语言的图形化编程 (11)2.2.4 Java的Socket编程 (12)2.4设计目标 (12)2.4.1基本性能 (12)2.4.2开发目标 (12)第三章系统设计 (13)3.1系统概要设计 (13)3.1.1软件用例图 (13)3.1.2软件总体分析 (14)3.2系统模块功能实现 (15)3.2.1 广播模块 (15)3.2.2 发送文件模块 (16)3.2.3 设置界面模块 (17)3.2.4 文件数据导入模块 (18)3.2.5监听模块 (19)3.2.6充当服务端模块 (20)第四章软件界面设计与程序主模块实现 (22)4.1界面设计 (22)4.1.1界面布局 (22)4.1.2用户区域 (22)4.1.3聊天区域 (22)4.2主模块与功能模块的组织实现 (23)4.2.1 主程序运行界面 (23)4.2.2 MainFrame.java组成 (24)第五章软件调试与测试 (26)5.1获取用户ip功能测试 (26)5.2发送文本消息模块测试 (27)5.3文件传输模块测试 (28)5.4设置模块测试 (30)第六章总结 (31)参考文献 (32)附录 (33)致谢 (35)第一章绪论1.1研究现状移动互联网背景下,通讯软件各种各样,通讯软件在各行各业中广泛应用,对于人与人之间的通信交流加强了人们沟通,局域网内的文件传输也促进了资源共享的便利;目前比较流行的通讯软件类别是即时通讯软件。
一“飞鸽传书2007绿色版”下载说明一个局域网通信软件,支持局域网间发信息、传送文件、文件夹、多文件(或文件夹),速度非常快。
有了它,局域网间传送文件不必再共享来共享去的了。
而且,该软件极度绿色哦:单个执行文件,完全与注册表、初始配置文件没有关系。
IPMsg是一款局域网内即时通信软件, 基于TCP/IP(UDP). 可运行于多种操作平台(Win/Mac/UNIX/Java), 并实现跨平台信息交流.- 不需要服务器支持.- 支持文件/文件夹的传送(2.00版以上) - 通讯数据采用RSA/Blofish加密(2.00版以上)- 十分小巧, 简单易用, 而且你可以完全免费使用它。
目前已有的版本包括: Win32, Win16, MacOS, MacOSX, X11, GTK, GNOME,Java等, 并且公开源代码.“飞鸽传书IP Messenger”唯一官方中文网址为: 中文域名:飞鸽传书二下载地址: IT168 软件屋天府软件SOHU 天极华军软件园斑马网天空软件硅谷动力CSDN 中国源码新浪网飞翔下载三关于飞鸽传书2007绿色版的重要声明最近接到举报,有人假借本站之名在各大下载网站发布了“飞鸽传书IP Messenger 2.71”、“QQ飞鸽传书”等,对此,我们郑重声明,“飞鸽传书IP Messenger”目前的较新版本为2.06版、2007绿色版,所谓的2.71版本根本不存在,其提供的软件包已被众多杀毒安全软件查出有病毒,请大家千万不要下载,以免威胁到自己的电脑安全!对于以“飞鸽传书”为名制造此恶意软件者,我们保留进一步追究其法律责任的权利!飞鸽传书追求INTERNET免费共享的精神,不断升级创新网络通信功能,造福广大网民!四飞鸽传书2007绿色版的相关说明系统要求Microsoft Windows 95/98/Me/NT4.0/2000/XP/200395/98/NT4.0 ... 要求comctl32.dll(公共控件) 的版本为5.x 或更高.(如果你安装的IE 是 5.x 或更高版本, 那么就不必担心这个问题了)注意: Windows 3.1(和NT3.5x), 请使用IP Messenger for Win16.使用说明:<安装/卸载>执行setup.exe 你可以将IPMsg安装到指定目录, 或者重新注册到启动组.如果需要删除IPMsg, 请先从控制面板中卸载, 再手动删除IPMsg目录.<系统托盘区图标>左键双击图标, 即可打开发送消息窗口.右键点击图标, 可进入[服务设置], [离开] 等.<发送消息窗口>- 发送消息时, 若勾选了[封装], 则接收者要先打开信封才能看到消息,如果你还勾选了[上锁], 则接收者在打开信封时还需要输入密码.(密码是由接收者自己在[服务设置] 中设置的)- 在发送信息窗口的右键功能菜单中,可以进行很多用户的自定义操作,将IPMSG个性化,如选择用户分组,自定义用户列表显示,搜索用户,设置窗口大小,固定窗口位置等。
飞鸽传书发文件方法介绍In the era of advanced technology and instant communication, it may seem archaic to discuss the methods of sending files using carrier pigeons, commonly known as "飞鸽传书" (fēi gē chuán shū) in Chinese. However, it is fascinating to explore the historical significance and practical aspects of this traditional method. This essay aims to introduce the concept of using carrier pigeons to send files, highlighting its benefits, challenges, and the emotional connection it fosters.Carrier pigeons have been used for centuries as a reliable means of communication, particularly in situations where traditional methods were impractical or unavailable. The process involves attaching a small, lightweight container to the leg of a trained pigeon, which carries the message or file to its intended recipient. This method gained popularity due to its efficiency, security, and ability to overcome geographical barriers.One of the significant advantages of using carrier pigeons is their remarkable speed and reliability. These birds possess an innate homing instinct, enabling them to navigate over long distances and return to their home roost. This natural ability makes them ideal for delivering filesor messages promptly, even in remote or inaccessible areas. Unlike other forms of communication, such as postalservices or electronic methods, carrier pigeons are not subject to delays caused by traffic congestion, technical glitches, or adverse weather conditions.Moreover, carrier pigeons offer a level of securitythat is difficult to replicate with modern methods. Thefiles or messages are securely enclosed in a container, preventing unauthorized access during transit. Thisphysical barrier adds an extra layer of protection,reducing the risk of sensitive information falling into the wrong hands. In an age where cybersecurity threats are prevalent, the simplicity and reliability of carrierpigeons can be a refreshing alternative.Despite the advantages, there are challenges associatedwith using carrier pigeons for file transfer. One significant limitation is the relatively small size of the container that can be attached to a pigeon's leg. This restricts the amount of data that can be sent at once, making it unsuitable for large files or complex data sets. Additionally, the reliance on physical transportation means that the speed of delivery is limited by the bird's flight capabilities. While carrier pigeons are swift, they cannot match the instantaneous transmission of digital files.Furthermore, the usage of carrier pigeons requires a certain level of training and expertise. It is essential to breed and train pigeons specifically for this purpose, ensuring they can navigate accurately and reliably. This process demands time, effort, and resources, making it less practical for everyday file transfer needs. Additionally, the availability and accessibility of trained carrier pigeons may vary depending on the region, limiting the widespread adoption of this method.Beyond the practical aspects, the concept of using carrier pigeons to send files evokes a sense of nostalgiaand human connection. In an era dominated by impersonal digital communication, the use of carrier pigeons brings a touch of tradition and romanticism. It symbolizes a slower pace of life and a return to simpler times when patienceand anticipation were valued. The act of releasing a pigeon with an important file or message creates a tangible connection between the sender and the recipient, fosteringa sense of intimacy and personal touch that is oftenlacking in modern communication.In conclusion, while the method of sending files using carrier pigeons may seem outdated, it is important to recognize its historical significance, practical advantages, and emotional appeal. Despite the limitations posed by file size and speed, carrier pigeons offer a reliable and secure means of communication, particularly in remote or inaccessible areas. Additionally, the use of carrierpigeons adds a touch of nostalgia and human connection toan increasingly digital world. While it may not be a practical solution for everyday file transfer, the conceptof "飞鸽传书" serves as a reminder of the beauty and simplicity of traditional communication methods.。
Mplayer 项目一、项目说明MPlayer是一款开源的多媒体播放器,以GNU通用公共许可证发布oMPlayer 是建基于命令行界面,在各作业系统可选择安装不同的图形界面。
Mplayer控制方式主要有键盘控制和命令行控制。
Mplayer项口是在Ubuntul2. 0. 4下实现,在基于A8内核的开发板上进行运行,所以该项Id采用了命令行控制模式进行对Mplayer 操作。
二、实现功能1)、该项LI主要实现了以下基本功能:1、能够播放歌曲文件2、能通过触摸屏按钮控制mplayer播放、暂停、快进、快退、上一首、下一首。
3、能通过物理按键控制mplayer播放、暂停、快进、快退、上一首、下一首。
4、显示歌曲列表,当前播放歌曲须要反显,点击对应歌曲能切换。
5、显示歌曲信息。
6、显示歌曲时间。
7、显示歌曲进度条。
8、显示歌曲对应的歌词,并且能够和歌曲同步。
9、能够自动换歌(播放完一首歌曲后,自动播放下一首歌)。
2)、创新点1、能够播放带空格的歌曲。
2、能够进行歌曲列表的翻页操作。
3、能够单击进度条进行随机播放。
三、项目步骤1、初始化显示屏在使用开发板的液晶屏前必需先初始化液晶屏,初始化液晶屏后我们才可以使用液晶屏的相关的函数,并且液晶屏的初始化函数应只调用一次,不可重复初始化,初始化液晶屏时可用函数TFT.Init (7dev/fbO")。
2、创建背景窗口,显示背景创建背景窗口可用函数TFT_CreateWindowEx ()。
组名:燃龙飞祥口号:飞得更商3、读歌曲口录,存歌曲名耳一函数使用opendir、readdir^ closedir函数读歌曲I」录的文件,创建数据库和表,保存歌曲文件的文件名。
4、打印歌曲列表写一函数将存储起来的歌曲名打印到屏幕上,打印时注意将正在播放的歌曲高亮、突出显示。
在调用打印函数前应设置打印位置,打印的颜色(即前景色,并且前景色与背景色应设置为不同的颜色)。
清除窗口内容可用函数TFT.ClearWindow ()。
IPMSG飞鸽传书通信协议/***********************************************************本人(ypxing)根据下面的协议,C语言写的ipmsg(聊天,文件/文件夹传输)*请参见:/u1/35100/showart_689330.html**********************************************************/最近看到一些朋友在编写网络程序是遇到一些问题,故把以前做IPMSG时翻译的文档贴过来,希望对网络编程新手有所帮助,在寻找编程项目的同学们也可参照此文档写出自己的IPMSG。
本文只包含其中几个比较重要的命令以及运行机制的中文翻译,更详细的内容请参照文后的IPMSG 协议英文文档声明:下述协议内容略去了一些在编写程序过程中没有用到协议内容,最初的Ipmsg协议是用日文写的,下面协议内容由本人(cugb_cat)翻译自Mr.Kanazawa的英文文档。
本翻译文档可任意传播和使用。
IP信使传输协议(第9版草案) 1996/02/212003/01/14 修订H.Shirouzushirouzu@h.email.ne.jp关于IP信使:IP信使使用TCP/UDP协议提供收发消息及文件(目录)。
特性:IP信使能够安装在任何一个安装了TCP/IP协议栈的操作系统上,使用在线用户的动态识别机制,可以和在线所有用户进行信息交换。
运行机制介绍:使用TCP/UDP端口(默认端口为2425),消息的收发使用UDP协议,文件(文件夹)的收发使用TCP协议。
1、命令字:1) 基本命令字(32位命令字的低8位)IPMSG_NOOPERATION 不进行任何操作IPMSG_BR_ENTRY 用户上线IPMSG_BR_EXIT 用户退出IPMSG_ANSENTRY 通报在线IPMSG_SENDMSG 发送消息IPMSG_RECVMSG 通报收到消息IPMSG_GETFILEDATA 请求通过TCP传输文件IPMSG_RELEASEFILES 停止接收文件IPMSG_GETDIRFILES 请求传输文件夹2) 选项位(32位命令字的高24位)IPMSG_SENDCHECKOPT 传送检查(需要对方返回确认信息)IPMSG_FILEATTACHOPT 传送文件选项3) 附件类型命令(文件类型命令字的低8位)IPMSG_FILE_REGULAR 普通文件IPMSG_FILE_DIR 目录文件IPMSG_FILE_RETPARENT 返回上一级目录2、数据包格式(使用字符串):1) 数据包格式(版本1的格式)版本号(1):包编号:发送者姓名:发送者主机名:命令字:附加信息2) 举例如下“1:100:shirouzu:Jupiter:32:Hello”3、数据包处理总述:1) 用户识别当IPMSG 启动时,命令IPMSG_BR_ENTRY被广播到网络中,向所有在线的用户提示一个新用户的到达(即表示“我来了”);所有在线用户将把该新上线用户添加到自己的用户列表中,并向该新上线用户发送IPMSG_ANSENTRY命令(即表示“我在线”);该新上线用户接收到IPMSG_ANSENTRY命令后即将在线用户添加到自己的用户列表中。
飞书鉴权java案例飞书(Feishu)是一款企业级即时通讯工具,类似于微信企业版。
飞书提供了丰富的API接口,用于实现各种功能,如消息发送、文件上传等。
下面是一个简单的Java案例,演示如何使用飞书的API进行鉴权和发送消息:```javaimport ;import ;import ;import ;public class FeishuAPIExample {private static final String APP_ID = "your_app_id";private static final String APP_SECRET = "your_app_secret";private static final String TO_USER = "";private static final String CONTENT = "Hello, Feishu!";public static void main(String[] args) throws Exception {// 获取access tokenString accessToken = getAccessToken();if (accessToken == null) {("Failed to get access token.");return;}// 发送消息sendMessage(accessToken, TO_USER, CONTENT);}private static String getAccessToken() throws Exception {String urlString = "URL url = new URL(urlString);HttpURLConnection connection = (HttpURLConnection) (); ("POST");("Content-Type", "application/json");(true);().write(("{" + " \"app_id\":\"" + APP_ID + "\"," + " \"app_secret\":\"" + APP_SECRET + "\"" + "}").getBytes("UTF-8"));BufferedReader br = new BufferedReader(new InputStreamReader((), "UTF-8"));String line;StringBuilder response = new StringBuilder();while ((line = ()) != null) {(line);}();();return ().split("\"")[1]; // 返回的JSON字符串中access_token的位置是第二个引号后的字符串,所以需要split掉第一个和第二个引号来获取access token。
目录飞鸽传书主界面ipmsg全称:IP Messenger,中文名为“飞鸽传书”,是一款由一个名叫H.Shirouzu的日本人开发和维护的用C语言写的局域网聊天和文件传输工具。
后来发展为很多志愿者共同开发多种版本。
它是一个小巧方便的即时通信软件,它适合用于局域网内甚至广域网间进行实时通信和文档共享。
特别是在局域网内传送文件/文件夹的效率很高。
它具有很多优点,如数据通讯不需要建立服务器、直接在两台电脑间通信和数据传输,支持文件及文件目录的传输,安全快捷以及小巧方便等优异特点,因此很多公司都采用它作为部门、公司内部的IM 即时通信工具。
Ipmsg - 功能介绍- IPMsg 是一款局域网内即时通信软件, 基于TCP/IP(UDP).可运行于多种操作平台(Win/Mac/UNIX/Java), 并实现跨平台信息交流.- 不需要服务器支持(软件本身集成了服务端和客户端)- 支持文件/文件夹的传送(2.00版以上)- 通讯数据采用RSA/Blofish 加密(2.00版以上)- 十分小巧, 简单易用, 而且可以完全免费使用它- 目前已有的版本包括: Win32, Win16, MacOS, MacOSX, X11, GTK, GNOME,Java 等,并且公开源代码。
Ipmsg - 源码简介IP Messenger在程序结构方面采用了Windows SDK处理结构,通信方面采用了TCP/UDP通信方式,在文件传输处理方面采用文件映射技术,等等。
通过分析IP Messenger 的运行、工作原理,可以提高并加深对Windows处理流程的理解,提高SOCKET编程技术等,因此特对其源码进行分析,以抛砖引玉,共同提高大家的编程技术。
1、IP Messenger源代码的下载在写这篇文章时,IP Messenger的最新版本是2.06,因此大家在下载时尽量选择最新版本下载。
IP Messenger源代码的下载地址是/,在网站的右上角,点击English page,网站转换到英文界面,网站有英文版以及其它语言的版本,当然还有中文版的链接(/IPMsg/),建议大家尽量下载原版的英文版源代码,以利于学习。
⾃⼰⽤java实现飞鸽传书2-实现⽂件传输第⼆步:实现⽂件传递。
上⼀步只是从服务端传递了⼀个字符串到客户端,这次需要对代码进⾏调整,实现从服务端获取⽂件,在客户端将⽂件存⼊⽬标地址。
调整后的代码:服务端:import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.File;import java.io.FileInputStream;import .ServerSocket;import .Socket;public class Server {public static void main(String[] args){//创建服务端socket,⽤以⽹络信息的接收ServerSocket serverSocket = null;try {//服务端socket使⽤本地IP,端⼝号使⽤36000serverSocket = new ServerSocket(36000);//保证服务端持续运⾏while(true){//接收⽹络信息,未接收到则阻塞当前线程Socket socket = serverSocket.accept();//将⽂件信息写⼊socket通信writeFile(socket);//关闭socket,防⽌客户端长时间等待socket.close();}} catch (Exception e) {e.printStackTrace();}}/*** 将⽂件信息写⼊socket通信流* @param socket* socket*/private static void writeFile(Socket socket){try{//获取本地⽂件String filePath ="D:/test.pdf";//创建⽂件对象File file = new File(filePath);//使⽤DataOutputStream传送⽂件信息DataOutputStream dos = new DataOutputStream(socket.getOutputStream());//写⼊⽂件名dos.writeUTF(file.getName());//写⼊⽂件⼤⼩dos.writeLong(file.length());//清空缓冲区dos.flush();//使⽤DataInputStream将⽂件写⼊DataInputStream dis = new DataInputStream( new FileInputStream(file) );byte[] buffer = new byte[1024];int head = 0;while((head=dis.read(buffer)) > 0){dos.write(buffer, 0, head);}dis.close();dos.close();}catch(Exception e){e.printStackTrace();}}}客户端:import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.FileOutputStream;import .Socket;public class Client {public static void main(String[] args){DataInputStream input = null;Socket clientSocket = null;try {//创建客户端socket,⽤以连接服务端clientSocket = new Socket("127.0.0.1", 36000);//读取服务端发送的信息流input = new DataInputStream(clientSocket.getInputStream());String fileName = input.readUTF();long fileSize = input.readLong();System.out.println("收到服务端发过来的⽂件,⽂件名称为:"+ fileName + ",⽂件⼤⼩为:" + fileSize);//将⽂件读⼊本地String savePath = "E:\\just a test.pdf";DataOutputStream fos = new DataOutputStream(new FileOutputStream(savePath));byte[] buffer = new byte[1024];int head = 0;while((head=input.read(buffer)) > 0){fos.write(buffer, 0, head);}fos.close();input.close();clientSocket.close();} catch (Exception e) {e.printStackTrace();}}}本次⽂件流的传送使⽤了DataOutputStream和DataInputStream,使⽤Data类型的字节流可以根据信息类型分别进⾏处理。
目录1 绪论 (1)1.1本程序的开发背景 (1)1.2开发环境 (1)1.3 Java语言 (1)1.4 关于Eclipse (2)2 程序结构和设计思想 (4)2.1本文解决的主要技术问题 (4)2.2程序设计结构 (4)2.3程序设计思想 (5)3 程序分析和具体实现 (7)3.1目录选择器 (7)3.2重要图形界面模块的实现 (10)3.3任务栏托盘图标和任务栏弹出对话框 (17)3.4信息收发和文件传输的实现 (21)3.5使用外部程序包 (28)3.6发布程序 (33)1 绪论1.1 本软件的开发背景当今,是一个信息高度发达的时代,计算机无疑已经成为网络通信的主角,生活节奏的加快,使得人们对通信速度的要求越来越高。
对于在局域网内的计算机之间的数据交互,尤其是文件传输,通常,人们习惯于通过借助于移动存储介质,采取重复拷贝的方式来实现。
这种传统文件传输方式存在诸多缺点,比如:1.消耗时间长,反复拔插存储介质过程繁琐;2.文件交互频繁,加速了计算机病毒的传播;3.虽然可以通过操作系统实现在局域网内的数据共享,但终因操作困难而使人们望而却步。
在如此多困难之下,人们不禁会考虑,能不能通过软件来实现计算机之间的数据交互?答案是肯定的。
本程序将针对这些问题进行设计。
1.2 开发环境操作系统:Microsoft Windows XP程序语言:Java 2开发包:Java(TM) 2 Standard Edition (6.0)开发平台:Eclipse 3.0+Swing Designer+JRE6.01.3 Java语言Java平台演进到Java2后,分别针对不同领域的需求被分成三个版本,亦即J2EE、J2SE、J2ME。
本程序使用J2SE。
J2SE是Java的标准版本 (Java2 Standard Edition),定位在客户端,主要用于桌面应用软件的编程。
J2SE 包含那些构成Java语言核心类库。
【摘要】为了方便内部网络的用户之间的沟通,我们需要开发一个基于局域网的信息共享工具。
本课题设计主要针对局域网通讯而开发设计的,采用的是C/S构架,类似飞鸽传书系统,来实现聊天、文件传输功能。
本设计以JAVA编写,能在windows 2000/net/xp等环境下运行。
设计共分为五大部分,分别是:1.选题背景及意义和国内外研究现状;2.TCP/IP点对点协议技术,C/S架构和SOCKET网络编程技术;3.对系统进行需求分析并提出解决方案;4.根据解决方案设计系统;5.测试系统并得到测试结果。
【关键词】聊天传输 socket 飞鸽传书 C/S结构 JAVADesign and Implementation IP Messenger Based on LAN and Java Technology【Abstract】In order to facilitate internal communication between network users, we need to develop one tool to share information. This topic design mainly aims at the local area network communication, use the C/S structure, like IP messenger, for chat and files transmission.This system is developed by JAVA and can run in the invironment of windows 2000/net/xp . The design altogether divides into five big parts, respectively is: 1. Selected topic background and significance, domestic and foreign research present situation; 2. TCP/IP point to point protocol technology, C/S structure and socket network programming technology; 3. Analyze the demand of this system and propose the solution; 4. According to the solution we design the system; 5. Test the system and obtains the test result.【Key words】chat transmission socket IP messenger C/S structure java目录绪论 (1)1 研究内容 (2)1.1TCP/IP (2)1.2主要研究思路和方法 (3)1.3研究系统的目的以及意义 (3)1.4J AVA SOCKET (3)2 系统需求分析 (9)2.1系统设计目标 (9)2.2系统总体需求分析 (9)2.3组织结构的分析 (9)2.3.1 开发运行环境 (10)2.3.2 系统开发语言 (10)3系统开发分析 (11)3.1C/S软件架构技术 (11)3.2用户数据报协议(UDP) (11)3.3单播、广播、组播浅析 (11)4系统设计 (13)4.1文字聊天模块的整体构架 (13)4.2文件传输模块的主要流程图 (13)4.3系统主要功能模块 (14)4.3.1 系统的主登录界面 (14)4.3.2 文字聊天信息的封装 (16)4.3.3 文件传输的界面 (18)5系统测试 (24)5.1测试环境 (24)5.2测试结果 (24)结论 (27)参考文献 (28)附录 (29)致谢....................................................... 错误!未定义书签。
飞鸽传书IP Messenger
纪升御
【期刊名称】《计算机应用文摘》
【年(卷),期】2003(000)013
【摘要】办公室的互联网连接中断,你和同事间的信息交流难道只有面对面或者打电话?要和一十远在他方的朋友进行交流.难道就必须让它击申请一个QQ,ICQ等即时通讯类软件需要的ID?不用这幺麻烦,试试IP Messenger吧!办公室互联网中断,你们之间可以通过它发进信息.传送文件;互联网上的朋友用它交流也不必去申请什么ID.更不必登录到任何服务器……
【总页数】2页(P41-42)
【作者】纪升御
【作者单位】无
【正文语种】中文
【中图分类】TP393
【相关文献】
1.IP Messenger聊天工具的设计 [J], 张春平
2.iPAQ转型——惠普iPAQ 510 Voice Messenger智能手机 [J], 无
3.Seeing through the Cosmic Ripples: Embrace the Era of Multi-messenger Astronomy [J], SONG Jianlan
4.Zipit Wireless Messenger2 [J],
5.CFPD Carrying Out the Mission and Responsibilities of “Messenger of
People-to-People Connectivity” and Participating in International Cooperation against COVID-19 [J], Ge Lei;Li Junling
因版权原因,仅展示原文概要,查看原文内容请购买。
飞鸽传书(java版)源代码.txt-//自私,让我们只看见自己却容不下别人。
如果发短信给你喜欢的人,他不回,不要再发。
看着你的相片,我就特冲动的想P成黑白挂墙上!有时,不是世界太虚伪,只是,我们太天真。
// About.javapackage networker.about;import java.awt.event.*;import java.awt.*;import javax.swing.*;import javax.swing.border.*;public class About extends JDialog {ClassLoader load=getClass().getClassLoader();ImageIcon icons=new ImageIcon(load.getResource("networker/Resource/Msg/msg1.png"));String msg=" 课题名称:基于java环境的网络编程\n 作者:姜力\n 指导老师:颜南明\n 创建时间:2008年4月";JTextArea area = new JTextArea(msg);JLabel icon = new JLabel();int width=310;int height=185;public About(JFrame jf) {super(jf,"关于",true);Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;setBounds( (w-width)/2, (h-height)/2,width,height);setResizable(false);Container content=getContentPane();content.setLayout(null);icon.setAlignmentX(Component.CENTER_ALIGNMENT);icon.setIcon(icons);area.setOpaque(false);area.setBorder(new TitledBorder(new EtchedBorder(), "关于此软件", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));area.setEditable(false);icon.setBounds(10, 20, 65, 60);area.setBounds(70, 20, 220, 110);content.add(icon);content.add(area);addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {dispose();}});setVisible(true);}}// Help.javapackage networker.about;import java.awt.event.*;import javax.swing.*;import java.awt.*;import javax.swing.tree.*;import javax.swing.event.*;import networker.system.*;public class Help extends JDialog implements TreeSelectionListener{ DefaultMutableTreeNode root = new DefaultMutableTreeNode("帮助");JTree tree = new JTree(root);DefaultTreeModel model = (DefaultTreeModel)tree.getModel();JTextArea text = new JTextArea();JScrollPane scroll = new JScrollPane(text);JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,tree,scroll);int width=500;int height=380;public Help(JFrame jf) {super(jf,"帮助",true);Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;setBounds( (w-width)/2, (h-height)/2,width,height);Container content=getContentPane();content.setLayout(new BorderLayout());content.add(splitPane, BorderLayout.CENTER);text.setLineWrap(false);text.setEditable(false);splitPane.setResizeWeight(0.55);splitPane.setDividerSize(10);initTree();addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {dispose();}});setVisible(true);}public void initTree(){tree.addTreeSelectionListener(this);//rootDefaultMutableTreeNode[] NO_0 = {new DefaultMutableTreeNode("软件说明"), new DefaultMutableTreeNode("主要功能"), new DefaultMutableTreeNode("操作方法"), new DefaultMutableTreeNode("修改信息"), new DefaultMutableTreeNode("好友管理"), new DefaultMutableTreeNode("更换皮肤")};for(int i=0;i<NO_0.length;i++)root.add(NO_0[i]);tree.expandPath(new TreePath(root));readText("帮助");}public void valueChanged(TreeSelectionEvent e) {TreePath paths = e.getNewLeadSelectionPath();String node=paths.getLastPathComponent().toString();readText(node);}public void readText(String title){text.setText(SystemInfo.getHelpDoc(title));if(title.equals("帮助")){text.setFont(new Font("Dialog",Font.PLAIN,16));text.setForeground(new Color(100,100,255));}else{text.setFont(new Font("Dialog",Font.PLAIN,14));text.setForeground(new Color(50,200,60));}}}// JavaPage.javapackage networker.about;import javax.swing.*;import javax.swing.JLabel;import java.awt.event.*;import java.awt.*;import ponents.*;public class JavaPage extends JDialog {ClassLoader load=getClass().getClassLoader();ImageIcon icon=new ImageIcon(load.getResource("networker/Resource/Msg/javainstall.png"));JLabel iconlabel=new JLabel();String Sun="",Eclipse="",JTattoo="",JDom="";JLabel sun = new JLabel("Sun公司官方网站:");LinkLabel sunlabel = new LinkLabel(Sun,Sun);JLabel eclipse = new JLabel("eclipse官方网站:");LinkLabel eclipselabel = new LinkLabel(Eclipse,Eclipse);JLabel jtattoo = new JLabel("JTattoo官方网站:");LinkLabel jtattoolabel = new LinkLabel(JTattoo,JTattoo);JLabel jdom = new JLabel("JDom官方网站:");LinkLabel jdomlabel = new LinkLabel(JDom,JDom);int width=435;int height=250;public JavaPage(JFrame jf,String title) {super(jf,title,true);setResizable(false);Container content=getContentPane();content.setLayout(null);Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;setBounds( (w-width)/2, (h-height)/2,width,height);iconlabel.setIcon(icon);sun.setBounds(135, 36, 117, 18);sunlabel.setBounds(264, 34, 123, 18);eclipse.setBounds(135, 73, 117, 18);eclipselabel.setBounds(264, 71, 167, 18);jtattoo.setBounds(135, 108, 117, 18);jtattoolabel.setBounds(264, 106, 143, 18);jdom.setBounds(135, 143, 117, 18);jdomlabel.setBounds(264, 141, 144, 18);iconlabel.setBounds(0,-15, 150, height);content.add(jdomlabel);content.add(sun);content.add(jdom);content.add(jtattoolabel);content.add(jtattoo);content.add(eclipselabel);content.add(eclipse);content.add(sunlabel);content.add(iconlabel);addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {dispose();}});setVisible(true);}}// TreeCell.javapackage networker.directorychooser;import javax.swing.*;import javax.swing.filechooser.FileSystemView;import java.io.*;public class TreeCell {public FileSystemView fsv=FileSystemView.getFileSystemView(); public File f;public TreeCell(File f){this.f=f;}public String getName(){return fsv.getSystemDisplayName(f);}public ImageIcon getIcon(){return (ImageIcon)fsv.getSystemIcon(f);}public String getFilePath(){if(fsv.isFileSystem(f))return f.getAbsolutePath();elsereturn null;}public File getFile(){return f;}}// DCTreeCellRenderer.javapackage networker.directorychooser;import javax.swing.*;import javax.swing.tree.*;import java.awt.*;class DCTreeCellRenderer extends JPanel implements TreeCellRenderer{ protected Color m_textSelectionColor;protected Color m_textNonSelectionColor;protected Color m_bkSelectionColor;protected Color m_bkNonSelectionColor;protected Color m_borderSelectionColor;protected boolean m_selected;JLabel text=new JLabel();JLabel icon=new JLabel();public DCTreeCellRenderer(){super();m_textSelectionColor = UIManager.getColor("Tree.selectionForeground");m_textNonSelectionColor = UIManager.getColor("Tree.textForeground");m_bkSelectionColor = UIManager.getColor("Tree.selectionBackground");m_bkNonSelectionColor = UIManager.getColor( "Tree.textBackground");m_borderSelectionColor = UIManager.getColor( "Tree.selectionBorderColor");setLayout(new FlowLayout());add(icon);add(text);setOpaque(false);text.setOpaque(true);icon.setOpaque(false);}public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,boolean leaf, int row, boolean hasFocus){DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;TreeCell v= (TreeCell)node.getUserObject();text.setText(v.getName());icon.setIcon(v.getIcon());if(sel){text.setForeground(m_textSelectionColor);text.setBackground(m_bkSelectionColor);}else{text.setForeground( m_textNonSelectionColor);text.setBackground(m_bkNonSelectionColor);}text.setFont(tree.getFont());return this;}}// DirectoryChooser.javapackage networker.directorychooser;import javax.swing.*;import javax.swing.tree.*;import java.awt.*;import java.awt.event.*;import javax.swing.event.*;import javax.swing.filechooser.*;import java.io.*;public class DirectoryChooser extends JDialog implements ActionListener,TreeWillExpandListener,TreeExpansionListener,TreeSelectionListener{ static FileSystemView fsv=FileSystemView.getFileSystemView();static File desk_File=fsv.getHomeDirectory();static String desk_Path=desk_File.getAbsolutePath();String desk_Name=fsv.getSystemDisplayName(desk_File);ImageIcon desk_Icon=(ImageIcon)fsv.getSystemIcon(desk_File);//布局组件JPanel panel_1 = new JPanel(new GridLayout(3,1));JPanel panel = new JPanel(new GridLayout(2,1));JLabel label_2 = new JLabel();JLabel label_1 = new JLabel("请选择要保存到的目录:");JPanel panel_5 = new JPanel();JPanel panel_4 = new JPanel(new FlowLayout(FlowLayout.CENTER));JPanel panel_2 = new JPanel();JPanel panel_3 = new JPanel();JLabel label = new JLabel("文件夹:");//应用组件JButton OkButton = new JButton("确定");JButton CancelButton = new JButton("取消");JTextField DirName = new JTextField();DefaultMutableTreeNode root=new DefaultMutableTreeNode(new TreeCell(desk_File));DefaultTreeModel model=new DefaultTreeModel(root);JTree tree = new JTree(model);JScrollPane scroll = new JScrollPane(tree);//对话框大小int Width=300;int Height=330;Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;//常用变量public static boolean CHOOSE_FLAG=false;public static String DIRECTORY_PATH=desk_Path;public DirectoryChooser(JFrame jf,String title){super(jf,title,true);Point p=jf.getLocation();int x=(int)p.getX();int y=(int)p.getY();initUI(x,y);addListener();}public DirectoryChooser(JDialog jd,String title){ super(jd,title,true);Point p=jd.getLocation();int x=(int)p.getX();int y=(int)p.getY();if(x<0)x=0;if(y<0)y=0;if(x+Width>w)x=w-Width;if(y+Height>h)y=h-Height;initUI(x,y);addListener();}private void initUI(int x,int y){Container content=getContentPane();content.setLayout(new BorderLayout());setBounds(x,y,Width,Height);setMinimumSize(new Dimension(Width,Height));content.add(panel_1, BorderLayout.NORTH);content.add(panel_2, BorderLayout.WEST);content.add(panel_3, BorderLayout.EAST);content.add(scroll, BorderLayout.CENTER);content.add(panel, BorderLayout.SOUTH);panel_1.add(label_2);panel_1.add(label_1);panel.add(panel_5);panel.add(panel_4);JLabel l=new JLabel();panel_4.add(OkButton);panel_4.add(l);panel_4.add(CancelButton);OkButton.setPreferredSize(new Dimension(90,30));CancelButton.setPreferredSize(new Dimension(90,30));l.setPreferredSize(new Dimension(30,30));panel_5.add(label);panel_5.add(DirName);label_1.setHorizontalAlignment(SwingConstants.CENTER);label_1.setFont(new Font("", Font.PLAIN, 14));label.setFont(new Font("", Font.PLAIN, 14));DirName.setPreferredSize(new Dimension(200, 25));TreeCellRenderer dc=new DCTreeCellRenderer();tree.setCellRenderer(dc);tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTI ON);initDesk();}private void addListener(){addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){dispose();}});OkButton.addActionListener(this);CancelButton.addActionListener(this);tree.setShowsRootHandles(true);tree.setEditable(false);tree.addTreeExpansionListener(this);tree.addTreeSelectionListener(this);}//按钮事件public void actionPerformed(ActionEvent e){JComponent c=(JComponent)e.getSource();if(c==OkButton){CHOOSE_FLAG=true;dispose();}if(c==CancelButton){CHOOSE_FLAG=false;dispose();}}//显示对话框public boolean ShowDialog(){setVisible(true);return CHOOSE_FLAG;}public void treeWillCollapse(TreeExpansionEvent ce){}public void treeWillExpand(TreeExpansionEvent ee){}public void treeCollapsed(TreeExpansionEvent ce){}public void treeExpanded(TreeExpansionEvent ee){TreePath tp=ee.getPath();DefaultMutableTreeNode node =(DefaultMutableTreeNode)tp.getLastPathComponent();int count=node.getChildCount();for(int i=0;i<count;i++){DefaultMutableTreeNodechild=(DefaultMutableTreeNode)node.getChildAt(i);addChild(child);}}public void valueChanged(TreeSelectionEvent tse){try{TreePath tp=tse.getNewLeadSelectionPath();DefaultMutableTreeNode node = (DefaultMutableTreeNode)tp.getLastPathComponent();TreeCell v= (TreeCell)node.getUserObject();String name=v.getName();DirName.setText(name);DIRECTORY_PATH=v.getFilePath();}catch(Exception e){}}//初始化桌面public void initDesk(){File[] fs=fsv.getFiles(desk_File,false);for(int i=0;i<fs.length;i++){if(fs[i].isDirectory()){TreeCell tc=new TreeCell(fs[i]);DefaultMutableTreeNode node=new DefaultMutableTreeNode(tc);root.add(node);addChild(node);}}//for endTreePath treepath=new TreePath(root);tree.expandPath(treepath);}public void addChild(DefaultMutableTreeNode node){try{if(node.isLeaf()){TreeCell v= (TreeCell)node.getUserObject();File f=v.getFile();File[] fs=fsv.getFiles(f,false);for(int i=0;i<fs.length;i++){if(fs[i].isDirectory()){TreeCell tc=new TreeCell(fs[i]);DefaultMutableTreeNode d=new DefaultMutableTreeNode(tc);node.add(d);}}//for end}}catch(Exception e){}}private String getFilePath(File f){if(fsv.isFileSystem(f))return f.getAbsolutePath();elsereturn null;}}// MButton.javapackage ponents;import javax.swing.*;import java.awt.*;import java.awt.event.*;public class MButton extends JButton implements MouseListener,MouseMotionListener{ ImageIcon img,img1;public MButton(ImageIcon img,ImageIcon img1,String text){this.img=img;this.img1=img1;setActionCommand(text);setIcon(img);setMargin(new Insets(0,0,0,0));setBorderPainted(false);setFocusPainted(false);setToolTipText(text);setContentAreaFilled(false);addMouseListener(this);addMouseMotionListener(this);}public void mousePressed(MouseEvent me) {setIcon(img);}public void mouseReleased(MouseEvent me){setIcon(img1);}public void mouseEntered(MouseEvent me) {setIcon(img1);}public void mouseExited(MouseEvent me) {setIcon(img);}public void mouseClicked(MouseEvent me){}public void mouseDragged(MouseEvent me){}public void mouseMoved(MouseEvent me) {}}// JumpFrame.javapackage ponents;import javax.swing.*;import java.awt.*;public class JumpFrame extends Thread{public JFrame jf;public int delay=0;public int count=0;public int len=0;public JumpFrame(JFrame jf,int delay,int count,int len){ this.jf=jf;this.delay=delay;this.count=count;this.len=len;start();}public void run(){Point p=jf.getLocation();int x=(int)(p.getX());int y=(int)(p.getY());for(int j=0;j<count;j++){jf.setLocation(x+len,y+len);try{Thread.sleep(delay);}catch(Exception e){}jf.setLocation(x-len,y+len);try{Thread.sleep(delay);}catch(Exception e){}jf.setLocation(x-len,y-len);try{Thread.sleep(delay);}catch(Exception e){}jf.setLocation(x+len,y-len);try{Thread.sleep(delay);}catch(Exception e){}}jf.setLocation(p);}}// RoundBorder.javapackage ponents;import java.awt.*;import java.awt.geom.RoundRectangle2D;import javax.swing.*;import javax.swing.border.AbstractBorder;public class RoundBorder extends AbstractBorder{UIDefaults uid = UIManager.getLookAndFeel().getDefaults();Color back= uid.getColor ("List.selectionBackground");int rw,rh;public RoundBorder(int rw,int rh){this.rw=rw;this.rh=rh;}public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){Graphics2D g2=(Graphics2D)g;RenderingHints hints=new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON );hints.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);g2.setRenderingHints(hints);g2.setColor(back);BasicStroke bs=new BasicStroke(3.0f);g2.setStroke(bs);g2.draw(new RoundRectangle2D.Float(x, y,width-1,height-1,rw,rh));}public Insets getBorderInsets(Component c){return new Insets(5,5,5,5);}public boolean isBorderOpaque(){return true;}}// UserItem.javapackage ponents;public class UserItem{String ComName;String IPName;String ImgPath;public UserItem (String ComName,String IPName,String ImgPath) {Name=ComName;this.IPName=IPName;this.ImgPath=ImgPath;}//setpublic void setComName(String ComName){Name=ComName;}public void setIPName(String IPName){this.IPName=IPName;}public void setImgPath(String ImgPath){this.ImgPath=ImgPath;}//getpublic String getComName(){return ComName;}public String getIPName(){return IPName;}public String getImgPath(){return ImgPath;}public static void main(String[] a){System.exit(0);}}// UserList.javapackage ponents;import java.awt.*;import ponent;import javax.swing.ListCellRenderer;import javax.swing.UIDefaults;import javax.swing.*;import networker.system.*;import networker.*;public class UserList extends JList{public UserList(){super();setCellRenderer(new MyRenderer());setModel(new DefaultListModel());setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); addMe();}public void addMe(){String MyComName=SystemInfo.getMyName();String IP=SystemInfo.getIPAddress();String img=SystemInfo.getImagePath();UserItem item=new UserItem(MyComName,IP,img);if(existsIP(IP))removeUserFromIP(IP);addUser(item);}public void addUser(UserItem item){DefaultListModel mod = (DefaultListModel) getModel();mod.addElement(item);}public void removeUser(UserItem item){DefaultListModel mod = (DefaultListModel) getModel();mod.removeElement(item);}public void removeUser(String username){int size=getModel().getSize();for(int i=0;i<size;i++){UserItem item=(UserItem)getModel().getElementAt(i);if(item.getComName().equals(username))removeUser(item);}}public void removeUserFromIP(String userIP){int size=getModel().getSize();for(int i=0;i<size;i++){UserItem item=(UserItem)getModel().getElementAt(i);if(item.getIPName().equals(userIP))removeUser(item);}}public UserItem[] getSelectedUser(){return (UserItem[])getSelectedValues();}public String getSelectedUserName(){try{return ((UserItem)getSelectedValue()).getIPName();}catch(Exception e){MainFrame.showStatus("请选择一个用户为发送对象!",Color.RED);return null;}}public String[] getAllUsers(){String[] res=new String[500];int cnt=0;int size=getModel().getSize();for(int i=0;i<size;i++){UserItem item=(UserItem)getModel().getElementAt(i);res[cnt++]=item.getComName();}return res;}public String[] getAllIPs(){String[] res=new String[500];int cnt=0;int size=getModel().getSize();for(int i=0;i<size;i++){UserItem item=(UserItem)getModel().getElementAt(i);res[cnt++]=item.getIPName();}return res;}//判断用户是否已在列表中public boolean exists(UserItem item){int size=getModel().getSize();for(int i=0;i<size;i++){UserItem items=(UserItem)getModel().getElementAt(i);if(items.getIPName().equals(item.getIPName()))return true;}return false;}public boolean existsIP(String ip){int size=getModel().getSize();for(int i=0;i<size;i++){UserItem items=(UserItem)getModel().getElementAt(i);if(items.getIPName().equals(ip))return true;}return false;}public void removeAllUser(){DefaultListModel mod = (DefaultListModel) getModel();mod.removeAllElements();addMe();}}class MyRenderer extends JPanel implements ListCellRenderer{JLabel l1=new JLabel(),l2=new JLabel(),l3=new JLabel(),l4=new JLabel();static Color listForeground,listBackground,listSelectionForeground,listSelectionBackground;static {UIDefaults uid = UIManager.getLookAndFeel().getDefaults();listForeground = uid.getColor ("List.foreground");listBackground = uid.getColor ("List.background");listSelectionForeground = uid.getColor ("List.selectionForeground");listSelectionBackground = uid.getColor ("List.selectionBackground");}public MyRenderer(){setOpaque(true);setLayout(new BorderLayout());l1.setOpaque(true);l2.setOpaque(true);l3.setOpaque(true);l4.setOpaque(true);l2.setForeground(Color.black);l3.setForeground(new Color(128,128,128));JPanel pane=new JPanel();pane.setLayout(new BorderLayout());pane.add(l2,BorderLayout.NORTH);pane.add(l3,BorderLayout.SOUTH);pane.add(l4,BorderLayout.CENTER);add(l1,BorderLayout.WEST);add(pane,BorderLayout.CENTER);}public Component getListCellRendererComponent(JList list,Object v,int index,boolean isSelected,boolean hasFocus){UserItem item=(UserItem)v;String img=item.getImgPath();String name=item.getComName();String ip=item.getIPName();ClassLoader load=getClass().getClassLoader();l1.setIcon(new ImageIcon(load.getResource(img)));l2.setText(name);l3.setText(ip);if(isSelected){setForeground(listSelectionForeground);setBackground(listSelectionBackground);l1.setBackground(listSelectionBackground);l2.setBackground(listSelectionBackground);l3.setBackground(listSelectionBackground);l4.setBackground(listSelectionBackground);}else{setForeground(listForeground);setBackground(listBackground);l1.setBackground(listBackground);l2.setBackground(listBackground);l3.setBackground(listBackground);l4.setBackground(listBackground);}return this;}}// LinkLabel.javapackage ponents;import javax.swing.*;import java.awt.event.*;import java.awt.*;import .*;public class LinkLabel extends JLabel {private String text, url;private boolean isSupported;public LinkLabel(String text, String url) {this.text = text;this.url = url;try {this.isSupported = Desktop.isDesktopSupported()&& Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);}catch (Exception e) {this.isSupported = false;}setText(false);addMouseListener(new MouseAdapter(){public void mouseEntered(MouseEvent e) {setText(isSupported);if (isSupported)setCursor(new Cursor(Cursor.HAND_CURSOR));}public void mouseExited(MouseEvent e) {setText(false);}public void mouseClicked(MouseEvent e) {try {Desktop.getDesktop().browse(new URI(LinkLabel.this.url));}catch (Exception ex){}}});}private void setText(boolean b) {if (!b)setText("<html><font color=blue><u>" + text);elsesetText("<html><font color=red><u>" + text);}}// ChangeMyMsg.javapackage networker;import javax.swing.*;import java.awt.*;import java.awt.event.*;import networker.system.*;public class ChangeMyMsg extends JDialog implements ActionListener{ String imgpath=SystemInfo.getImagePath();ClassLoader load=getClass().getClassLoader();private JComboBox box = new JComboBox();private JTextField MyName = new JTextField(30);JLabel label1 = new JLabel("用户名:");JLabel label2 = new JLabel("头像:");JButton OkButton = new JButton("确定");JLabel label = new JLabel();int width=250;int height=150;MainFrame mf;public ChangeMyMsg(MainFrame mf) {super(mf,"更改信息",true);this.mf=mf;Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;setBounds( (w-width)/2, (h-height)/2,width,height);setResizable(false);Container content=getContentPane();content.setLayout(null);label.setForeground(Color.red);label.setBounds(10, 90, 150, 25);label1.setBounds(15, 15, 60, 25);label2.setBounds(15, 60, 60, 25);MyName.setBounds(70, 13, 100, 30);OkButton.setBounds(175, 80, 60, 30);box.setBounds(70, 50, 100, 50);box.setRenderer(new MyRenderer());initCombo();content.add(OkButton);content.add(label1);content.add(label2);content.add(MyName);content.add(box);content.add(label);init();OkButton.addActionListener(this);addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){dispose();}});setVisible(true);}public void actionPerformed(ActionEvent e){String newName=MyName.getText();ImagePath l=(ImagePath)box.getSelectedItem();String path=l.path;if(newName==null||newName.trim().equals("")) label.setText("用户名不能为空!");else{SystemInfo.setImagePath(path);SystemInfo.setMyName(newName);mf.mmp.paintPane();mf.list.addMe();dispose();}}public void initCombo(){for(int i=1;i<26;i++){ImagePath path=new ImagePath("networker/UserPhotos/"+String.valueOf(i)+".gif");box.addItem(path);}box.setSelectedIndex(getIndex(imgpath));}private int getIndex(String m){for(int i=1;i<26;i++){ImagePath ip=(ImagePath)box.getItemAt(i);String str=ip.getPath();if(m.equals(str))return i;}return 1;}public void init(){String name=SystemInfo.getMyName();MyName.setText(name);String path=SystemInfo.getImagePath();ImagePath p=new ImagePath(path);box.setSelectedItem(p);}}// ImagePath.javapackage networker;public class ImagePath{String path;public ImagePath(String path){this.path=path;}public String getPath(){return path;}}// MainFrame.javapackage networker;import javax.swing.*;import java.awt.event.*;import java.awt.*;import .*;import java.io.*;import javax.swing.text.*;import com.jtattoo.plaf.aero.*;import com.jtattoo.plaf.hifi.*;import com.jtattoo.plaf.mcwin.*;import com.jtattoo.plaf.mint.*;import networker.panels.*;import networker.directorychooser.DirectoryChooser;import ponents.*;import networker.system.*;import networker.taskbardialog.DefaultSavaPath;import networker.panels.filepane.*;import networker.about.*;public class MainFrame extends JFrame implements ActionListener,ItemListener{ClassLoader load=getClass().getClassLoader();String Name,IP;//菜单栏JMenuBar MBar=new JMenuBar();JMenu FileMenu=new JMenu("文件"),SetMenu=new JMenu("设置"),SkinMenu=new JMenu("皮肤"),HelpMenu=new JMenu("帮助");JMenuItem[] items={ new JMenuItem("传送文件"),new JMenuItem("传送文件夹"),new JMenuItem("隐藏窗口"),new JMenuItem("退出程序"),new JMenuItem("扫描用户"),new JMenuItem("更改信息"),new JMenuItem("添加好友"),new JMenuItem("帮助"),new JMenuItem("关于此软件"),new JMenuItem("设置默认存取目录"),new JMenuItem("Java相关网站")};JRadioButtonMenuItem[] skinitems={ new JRadioButtonMenuItem("蓝色主题"), new JRadioButtonMenuItem("黑色主题"),new JRadioButtonMenuItem("苹果主题"),new JRadioButtonMenuItem("绿色主题") };。
// About.javapackage networker.about;import java.awt.event.*;import java.awt.*;import javax.swing.*;import javax.swing.border.*;public class About extends JDialog {ClassLoader load=getClass().getClassLoader();ImageIcon icons=new ImageIcon(load.getResource("networker/Resource/Msg/msg1.png"));String msg=" 课题名称:基于java环境的网络编程\n 作者:姜力\n 指导老师:颜南明\n 创建时间:2008年4月";JTextArea area = new JTextArea(msg);JLabel icon = new JLabel();int width=310;int height=185;public About(JFrame jf) {super(jf,"关于",true);Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;setBounds( (w-width)/2, (h-height)/2,width,height);setResizable(false);Container content=getContentPane();content.setLayout(null);icon.setAlignmentX(Component.CENTER_ALIGNMENT);icon.setIcon(icons);area.setOpaque(false);area.setBorder(new TitledBorder(new EtchedBorder(), "关于此软件", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));area.setEditable(false);icon.setBounds(10, 20, 65, 60);area.setBounds(70, 20, 220, 110);content.add(icon);content.add(area);addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {dispose();}});setVisible(true);}}// Help.javapackage networker.about;import java.awt.event.*;import javax.swing.*;import java.awt.*;import javax.swing.tree.*;import javax.swing.event.*;import networker.system.*;public class Help extends JDialog implements TreeSelectionListener{ DefaultMutableTreeNode root = new DefaultMutableTreeNode("帮助");JTree tree = new JTree(root);DefaultTreeModel model = (DefaultTreeModel)tree.getModel();JTextArea text = new JTextArea();JScrollPane scroll = new JScrollPane(text);JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,tree,scroll);int width=500;int height=380;public Help(JFrame jf) {super(jf,"帮助",true);Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;setBounds( (w-width)/2, (h-height)/2,width,height);Container content=getContentPane();content.setLayout(new BorderLayout());content.add(splitPane, BorderLayout.CENTER);text.setLineWrap(false);text.setEditable(false);splitPane.setResizeWeight(0.55);splitPane.setDividerSize(10);initTree();addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {dispose();}});setVisible(true);}public void initTree(){tree.addTreeSelectionListener(this);//rootDefaultMutableTreeNode[] NO_0 = {new DefaultMutableTreeNode("软件说明"), new DefaultMutableTreeNode("主要功能"), new DefaultMutableTreeNode("操作方法"), new DefaultMutableTreeNode("修改信息"), new DefaultMutableTreeNode("好友管理"), new DefaultMutableTreeNode("更换皮肤")};for(int i=0;i<NO_0.length;i++)root.add(NO_0[i]);tree.expandPath(new TreePath(root));readText("帮助");}public void valueChanged(TreeSelectionEvent e) {TreePath paths = e.getNewLeadSelectionPath();String node=paths.getLastPathComponent().toString();readText(node);}public void readText(String title){text.setText(SystemInfo.getHelpDoc(title));if(title.equals("帮助")){text.setFont(new Font("Dialog",Font.PLAIN,16));text.setForeground(new Color(100,100,255));}else{text.setFont(new Font("Dialog",Font.PLAIN,14));text.setForeground(new Color(50,200,60));}}}// JavaPage.javapackage networker.about;import javax.swing.*;import javax.swing.JLabel;import java.awt.event.*;import java.awt.*;import ponents.*;public class JavaPage extends JDialog {ClassLoader load=getClass().getClassLoader();ImageIcon icon=new ImageIcon(load.getResource("networker/Resource/Msg/javainstall.png"));JLabel iconlabel=new JLabel();String Sun="",Eclipse="",JTattoo="",JDom="";JLabel sun = new JLabel("Sun公司官方网站:");LinkLabel sunlabel = new LinkLabel(Sun,Sun);JLabel eclipse = new JLabel("eclipse官方网站:");LinkLabel eclipselabel = new LinkLabel(Eclipse,Eclipse);JLabel jtattoo = new JLabel("JTattoo官方网站:");LinkLabel jtattoolabel = new LinkLabel(JTattoo,JTattoo);JLabel jdom = new JLabel("JDom官方网站:");LinkLabel jdomlabel = new LinkLabel(JDom,JDom);int width=435;int height=250;public JavaPage(JFrame jf,String title) {super(jf,title,true);setResizable(false);Container content=getContentPane();content.setLayout(null);Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;setBounds( (w-width)/2, (h-height)/2,width,height);iconlabel.setIcon(icon);sun.setBounds(135, 36, 117, 18);sunlabel.setBounds(264, 34, 123, 18);eclipse.setBounds(135, 73, 117, 18);eclipselabel.setBounds(264, 71, 167, 18);jtattoo.setBounds(135, 108, 117, 18);jtattoolabel.setBounds(264, 106, 143, 18);jdom.setBounds(135, 143, 117, 18);jdomlabel.setBounds(264, 141, 144, 18);iconlabel.setBounds(0,-15, 150, height);content.add(jdomlabel);content.add(sun);content.add(jdom);content.add(jtattoolabel);content.add(jtattoo);content.add(eclipselabel);content.add(eclipse);content.add(sunlabel);content.add(iconlabel);addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {dispose();}});setVisible(true);}}// TreeCell.javapackage networker.directorychooser;import javax.swing.*;import javax.swing.filechooser.FileSystemView;import java.io.*;public class TreeCell {public FileSystemView fsv=FileSystemView.getFileSystemView(); public File f;public TreeCell(File f){this.f=f;}public String getName(){return fsv.getSystemDisplayName(f);}public ImageIcon getIcon(){return (ImageIcon)fsv.getSystemIcon(f);}public String getFilePath(){if(fsv.isFileSystem(f))return f.getAbsolutePath();elsereturn null;}public File getFile(){return f;}}// DCTreeCellRenderer.javapackage networker.directorychooser;import javax.swing.*;import javax.swing.tree.*;import java.awt.*;class DCTreeCellRenderer extends JPanel implements TreeCellRenderer{ protected Color m_textSelectionColor;protected Color m_textNonSelectionColor;protected Color m_bkSelectionColor;protected Color m_bkNonSelectionColor;protected Color m_borderSelectionColor;protected boolean m_selected;JLabel text=new JLabel();JLabel icon=new JLabel();public DCTreeCellRenderer(){super();m_textSelectionColor = UIManager.getColor("Tree.selectionForeground");m_textNonSelectionColor = UIManager.getColor("Tree.textForeground");m_bkSelectionColor = UIManager.getColor("Tree.selectionBackground");m_bkNonSelectionColor = UIManager.getColor( "Tree.textBackground");m_borderSelectionColor = UIManager.getColor( "Tree.selectionBorderColor");setLayout(new FlowLayout());add(icon);add(text);setOpaque(false);text.setOpaque(true);icon.setOpaque(false);}public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,boolean leaf, int row, boolean hasFocus){DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;TreeCell v= (TreeCell)node.getUserObject();text.setText(v.getName());icon.setIcon(v.getIcon());if(sel){text.setForeground(m_textSelectionColor);text.setBackground(m_bkSelectionColor);}else{text.setForeground( m_textNonSelectionColor);text.setBackground(m_bkNonSelectionColor);}text.setFont(tree.getFont());return this;}}// DirectoryChooser.javapackage networker.directorychooser;import javax.swing.*;import javax.swing.tree.*;import java.awt.*;import java.awt.event.*;import javax.swing.event.*;import javax.swing.filechooser.*;import java.io.*;public class DirectoryChooser extends JDialog implements ActionListener,TreeWillExpandListener,TreeExpansionListener,TreeSelectionListener{ static FileSystemView fsv=FileSystemView.getFileSystemView();static File desk_File=fsv.getHomeDirectory();static String desk_Path=desk_File.getAbsolutePath();String desk_Name=fsv.getSystemDisplayName(desk_File);ImageIcon desk_Icon=(ImageIcon)fsv.getSystemIcon(desk_File);//布局组件JPanel panel_1 = new JPanel(new GridLayout(3,1));JPanel panel = new JPanel(new GridLayout(2,1));JLabel label_2 = new JLabel();JLabel label_1 = new JLabel("请选择要保存到的目录:");JPanel panel_5 = new JPanel();JPanel panel_4 = new JPanel(new FlowLayout(FlowLayout.CENTER));JPanel panel_2 = new JPanel();JPanel panel_3 = new JPanel();JLabel label = new JLabel("文件夹:");//应用组件JButton OkButton = new JButton("确定");JButton CancelButton = new JButton("取消");JTextField DirName = new JTextField();DefaultMutableTreeNode root=new DefaultMutableTreeNode(new TreeCell(desk_File));DefaultTreeModel model=new DefaultTreeModel(root);JTree tree = new JTree(model);JScrollPane scroll = new JScrollPane(tree);//对话框大小int Width=300;int Height=330;Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;//常用变量public static boolean CHOOSE_FLAG=false;public static String DIRECTORY_PATH=desk_Path;public DirectoryChooser(JFrame jf,String title){super(jf,title,true);Point p=jf.getLocation();int x=(int)p.getX();int y=(int)p.getY();initUI(x,y);addListener();}public DirectoryChooser(JDialog jd,String title){ super(jd,title,true);Point p=jd.getLocation();int x=(int)p.getX();int y=(int)p.getY();if(x<0)x=0;if(y<0)y=0;if(x+Width>w)x=w-Width;if(y+Height>h)y=h-Height;initUI(x,y);addListener();}private void initUI(int x,int y){Container content=getContentPane();content.setLayout(new BorderLayout());setBounds(x,y,Width,Height);setMinimumSize(new Dimension(Width,Height));content.add(panel_1, BorderLayout.NORTH);content.add(panel_2, BorderLayout.WEST);content.add(panel_3, BorderLayout.EAST);content.add(scroll, BorderLayout.CENTER);content.add(panel, BorderLayout.SOUTH);panel_1.add(label_2);panel_1.add(label_1);panel.add(panel_5);panel.add(panel_4);JLabel l=new JLabel();panel_4.add(OkButton);panel_4.add(l);panel_4.add(CancelButton);OkButton.setPreferredSize(new Dimension(90,30));CancelButton.setPreferredSize(new Dimension(90,30)); l.setPreferredSize(new Dimension(30,30));panel_5.add(label);panel_5.add(DirName);label_1.setHorizontalAlignment(SwingConstants.CENTER);label_1.setFont(new Font("", Font.PLAIN, 14));label.setFont(new Font("", Font.PLAIN, 14));DirName.setPreferredSize(new Dimension(200, 25));TreeCellRenderer dc=new DCTreeCellRenderer();tree.setCellRenderer(dc);tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTI ON);initDesk();}private void addListener(){addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){dispose();}});OkButton.addActionListener(this);CancelButton.addActionListener(this);tree.setShowsRootHandles(true);tree.setEditable(false);tree.addTreeExpansionListener(this);tree.addTreeSelectionListener(this);}//按钮事件public void actionPerformed(ActionEvent e){JComponent c=(JComponent)e.getSource();if(c==OkButton){CHOOSE_FLAG=true;dispose();}if(c==CancelButton){CHOOSE_FLAG=false;dispose();}}//显示对话框public boolean ShowDialog(){setVisible(true);return CHOOSE_FLAG;}public void treeWillCollapse(TreeExpansionEvent ce){}public void treeWillExpand(TreeExpansionEvent ee){}public void treeCollapsed(TreeExpansionEvent ce){}public void treeExpanded(TreeExpansionEvent ee){TreePath tp=ee.getPath();DefaultMutableTreeNode node =(DefaultMutableTreeNode)tp.getLastPathComponent();int count=node.getChildCount();for(int i=0;i<count;i++){DefaultMutableTreeNodechild=(DefaultMutableTreeNode)node.getChildAt(i);addChild(child);}}public void valueChanged(TreeSelectionEvent tse){try{TreePath tp=tse.getNewLeadSelectionPath();DefaultMutableTreeNode node = (DefaultMutableTreeNode)tp.getLastPathComponent();TreeCell v= (TreeCell)node.getUserObject();String name=v.getName();DirName.setText(name);DIRECTORY_PATH=v.getFilePath();}catch(Exception e){}}//初始化桌面public void initDesk(){File[] fs=fsv.getFiles(desk_File,false);for(int i=0;i<fs.length;i++){if(fs[i].isDirectory()){TreeCell tc=new TreeCell(fs[i]);DefaultMutableTreeNode node=new DefaultMutableTreeNode(tc);root.add(node);addChild(node);}}//for endTreePath treepath=new TreePath(root);tree.expandPath(treepath);}public void addChild(DefaultMutableTreeNode node){try{if(node.isLeaf()){TreeCell v= (TreeCell)node.getUserObject();File f=v.getFile();File[] fs=fsv.getFiles(f,false);for(int i=0;i<fs.length;i++){if(fs[i].isDirectory()){TreeCell tc=new TreeCell(fs[i]);DefaultMutableTreeNode d=new DefaultMutableTreeNode(tc);node.add(d);}}//for end}}catch(Exception e){}}private String getFilePath(File f){if(fsv.isFileSystem(f))return f.getAbsolutePath();elsereturn null;}}// MButton.javapackage ponents;import javax.swing.*;import java.awt.*;import java.awt.event.*;public class MButton extends JButton implements MouseListener,MouseMotionListener{ ImageIcon img,img1;public MButton(ImageIcon img,ImageIcon img1,String text){this.img=img;this.img1=img1;setActionCommand(text);setIcon(img);setMargin(new Insets(0,0,0,0));setBorderPainted(false);setFocusPainted(false);setToolTipText(text);setContentAreaFilled(false);addMouseListener(this);addMouseMotionListener(this);}public void mousePressed(MouseEvent me) {setIcon(img);}public void mouseReleased(MouseEvent me){setIcon(img1);}public void mouseEntered(MouseEvent me) {setIcon(img1);}public void mouseExited(MouseEvent me) {setIcon(img);}public void mouseClicked(MouseEvent me){}public void mouseDragged(MouseEvent me){}public void mouseMoved(MouseEvent me) {}}// JumpFrame.javapackage ponents;import javax.swing.*;import java.awt.*;public class JumpFrame extends Thread{public JFrame jf;public int delay=0;public int count=0;public int len=0;public JumpFrame(JFrame jf,int delay,int count,int len){ this.jf=jf;this.delay=delay;this.count=count;this.len=len;start();}public void run(){Point p=jf.getLocation();int x=(int)(p.getX());int y=(int)(p.getY());for(int j=0;j<count;j++){jf.setLocation(x+len,y+len);try{Thread.sleep(delay);}catch(Exception e){}jf.setLocation(x-len,y+len);try{Thread.sleep(delay);}catch(Exception e){}jf.setLocation(x-len,y-len);try{Thread.sleep(delay);}catch(Exception e){}jf.setLocation(x+len,y-len);try{Thread.sleep(delay);}catch(Exception e){}}jf.setLocation(p);}}// RoundBorder.javapackage ponents;import java.awt.*;import java.awt.geom.RoundRectangle2D;import javax.swing.*;import javax.swing.border.AbstractBorder;public class RoundBorder extends AbstractBorder{UIDefaults uid = UIManager.getLookAndFeel().getDefaults();Color back= uid.getColor ("List.selectionBackground");int rw,rh;public RoundBorder(int rw,int rh){this.rw=rw;this.rh=rh;}public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){Graphics2D g2=(Graphics2D)g;RenderingHints hints=new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON );hints.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);g2.setRenderingHints(hints);g2.setColor(back);BasicStroke bs=new BasicStroke(3.0f);g2.setStroke(bs);g2.draw(new RoundRectangle2D.Float(x, y,width-1,height-1,rw,rh));}public Insets getBorderInsets(Component c){return new Insets(5,5,5,5);}public boolean isBorderOpaque(){return true;}}// UserItem.javapackage ponents;public class UserItem{String ComName;String IPName;String ImgPath;public UserItem (String ComName,String IPName,String ImgPath) {Name=ComName;this.IPName=IPName;this.ImgPath=ImgPath;}//setpublic void setComName(String ComName){Name=ComName;}public void setIPName(String IPName){this.IPName=IPName;}public void setImgPath(String ImgPath){this.ImgPath=ImgPath;}//getpublic String getComName(){return ComName;}public String getIPName(){return IPName;}public String getImgPath(){return ImgPath;}public static void main(String[] a){System.exit(0);}}// UserList.javapackage ponents;import java.awt.*;import ponent;import javax.swing.ListCellRenderer;import javax.swing.UIDefaults;import javax.swing.*;import networker.system.*;import networker.*;public class UserList extends JList{public UserList(){super();setCellRenderer(new MyRenderer());setModel(new DefaultListModel());setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); addMe();}public void addMe(){String MyComName=SystemInfo.getMyName();String IP=SystemInfo.getIPAddress();String img=SystemInfo.getImagePath();UserItem item=new UserItem(MyComName,IP,img);if(existsIP(IP))removeUserFromIP(IP);addUser(item);}public void addUser(UserItem item){DefaultListModel mod = (DefaultListModel) getModel();mod.addElement(item);}public void removeUser(UserItem item){DefaultListModel mod = (DefaultListModel) getModel();mod.removeElement(item);}public void removeUser(String username){int size=getModel().getSize();for(int i=0;i<size;i++){UserItem item=(UserItem)getModel().getElementAt(i);if(item.getComName().equals(username))removeUser(item);}}public void removeUserFromIP(String userIP){int size=getModel().getSize();for(int i=0;i<size;i++){UserItem item=(UserItem)getModel().getElementAt(i);if(item.getIPName().equals(userIP))removeUser(item);}}public UserItem[] getSelectedUser(){return (UserItem[])getSelectedValues();}public String getSelectedUserName(){try{return ((UserItem)getSelectedValue()).getIPName();}catch(Exception e){MainFrame.showStatus("请选择一个用户为发送对象!",Color.RED);return null;}}public String[] getAllUsers(){String[] res=new String[500];int cnt=0;int size=getModel().getSize();for(int i=0;i<size;i++){UserItem item=(UserItem)getModel().getElementAt(i);res[cnt++]=item.getComName();}return res;}public String[] getAllIPs(){String[] res=new String[500];int cnt=0;int size=getModel().getSize();for(int i=0;i<size;i++){UserItem item=(UserItem)getModel().getElementAt(i);res[cnt++]=item.getIPName();}return res;}//判断用户是否已在列表中public boolean exists(UserItem item){int size=getModel().getSize();for(int i=0;i<size;i++){UserItem items=(UserItem)getModel().getElementAt(i);if(items.getIPName().equals(item.getIPName()))return true;}return false;}public boolean existsIP(String ip){int size=getModel().getSize();for(int i=0;i<size;i++){UserItem items=(UserItem)getModel().getElementAt(i);if(items.getIPName().equals(ip))return true;}return false;}public void removeAllUser(){DefaultListModel mod = (DefaultListModel) getModel();mod.removeAllElements();addMe();}}class MyRenderer extends JPanel implements ListCellRenderer{JLabel l1=new JLabel(),l2=new JLabel(),l3=new JLabel(),l4=new JLabel();static Color listForeground,listBackground,listSelectionForeground,listSelectionBackground;static {UIDefaults uid = UIManager.getLookAndFeel().getDefaults();listForeground = uid.getColor ("List.foreground");listBackground = uid.getColor ("List.background");listSelectionForeground = uid.getColor ("List.selectionForeground");listSelectionBackground = uid.getColor ("List.selectionBackground");}public MyRenderer(){setOpaque(true);setLayout(new BorderLayout());l1.setOpaque(true);l2.setOpaque(true);l3.setOpaque(true);l4.setOpaque(true);l2.setForeground(Color.black);l3.setForeground(new Color(128,128,128));JPanel pane=new JPanel();pane.setLayout(new BorderLayout());pane.add(l2,BorderLayout.NORTH);pane.add(l3,BorderLayout.SOUTH);pane.add(l4,BorderLayout.CENTER);add(l1,BorderLayout.WEST);add(pane,BorderLayout.CENTER);}public Component getListCellRendererComponent(JList list,Object v,int index,boolean isSelected,boolean hasFocus){UserItem item=(UserItem)v;String img=item.getImgPath();String name=item.getComName();String ip=item.getIPName();ClassLoader load=getClass().getClassLoader();l1.setIcon(new ImageIcon(load.getResource(img)));l2.setText(name);l3.setText(ip);if(isSelected){setForeground(listSelectionForeground);setBackground(listSelectionBackground);l1.setBackground(listSelectionBackground);l2.setBackground(listSelectionBackground);l3.setBackground(listSelectionBackground);l4.setBackground(listSelectionBackground);}else{setForeground(listForeground);setBackground(listBackground);l1.setBackground(listBackground);l2.setBackground(listBackground);l3.setBackground(listBackground);l4.setBackground(listBackground);}return this;}}// LinkLabel.javapackage ponents;import javax.swing.*;import java.awt.event.*;import java.awt.*;import .*;public class LinkLabel extends JLabel {private String text, url;private boolean isSupported;public LinkLabel(String text, String url) {this.text = text;this.url = url;try {this.isSupported = Desktop.isDesktopSupported()&& Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);}catch (Exception e) {this.isSupported = false;}setText(false);addMouseListener(new MouseAdapter(){public void mouseEntered(MouseEvent e) {setText(isSupported);if (isSupported)setCursor(new Cursor(Cursor.HAND_CURSOR));}public void mouseExited(MouseEvent e) {setText(false);}public void mouseClicked(MouseEvent e) {try {Desktop.getDesktop().browse(new URI(LinkLabel.this.url));}catch (Exception ex){}}});}private void setText(boolean b) {if (!b)setText("<html><font color=blue><u>" + text);elsesetText("<html><font color=red><u>" + text);}}// ChangeMyMsg.javapackage networker;import javax.swing.*;import java.awt.*;import java.awt.event.*;import networker.system.*;public class ChangeMyMsg extends JDialog implements ActionListener{ String imgpath=SystemInfo.getImagePath();ClassLoader load=getClass().getClassLoader();private JComboBox box = new JComboBox();private JTextField MyName = new JTextField(30);JLabel label1 = new JLabel("用户名:");JLabel label2 = new JLabel("头像:");JButton OkButton = new JButton("确定");JLabel label = new JLabel();int width=250;int height=150;MainFrame mf;public ChangeMyMsg(MainFrame mf) {super(mf,"更改信息",true);this.mf=mf;Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();int w=screen.width;int h=screen.height;setBounds( (w-width)/2, (h-height)/2,width,height);setResizable(false);Container content=getContentPane();content.setLayout(null);label.setForeground(Color.red);label.setBounds(10, 90, 150, 25);label1.setBounds(15, 15, 60, 25);label2.setBounds(15, 60, 60, 25);MyName.setBounds(70, 13, 100, 30);OkButton.setBounds(175, 80, 60, 30);box.setBounds(70, 50, 100, 50);box.setRenderer(new MyRenderer());initCombo();content.add(OkButton);content.add(label1);content.add(label2);content.add(MyName);content.add(box);content.add(label);init();OkButton.addActionListener(this);addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){dispose();}});setVisible(true);}public void actionPerformed(ActionEvent e){String newName=MyName.getText();ImagePath l=(ImagePath)box.getSelectedItem();String path=l.path;if(newName==null||newName.trim().equals("")) label.setText("用户名不能为空!");else{SystemInfo.setImagePath(path);SystemInfo.setMyName(newName);mf.mmp.paintPane();mf.list.addMe();dispose();}}public void initCombo(){for(int i=1;i<26;i++){ImagePath path=new ImagePath("networker/UserPhotos/"+String.valueOf(i)+".gif");box.addItem(path);}box.setSelectedIndex(getIndex(imgpath));}private int getIndex(String m){for(int i=1;i<26;i++){ImagePath ip=(ImagePath)box.getItemAt(i);String str=ip.getPath();if(m.equals(str))return i;}return 1;}public void init(){String name=SystemInfo.getMyName();MyName.setText(name);String path=SystemInfo.getImagePath();ImagePath p=new ImagePath(path);box.setSelectedItem(p);}}// ImagePath.javapackage networker;public class ImagePath{String path;public ImagePath(String path){this.path=path;}public String getPath(){return path;}}// MainFrame.javapackage networker;import javax.swing.*;import java.awt.event.*;import java.awt.*;import .*;import java.io.*;import javax.swing.text.*;import com.jtattoo.plaf.aero.*;import com.jtattoo.plaf.hifi.*;import com.jtattoo.plaf.mcwin.*;import com.jtattoo.plaf.mint.*;import networker.panels.*;import networker.directorychooser.DirectoryChooser;import ponents.*;import networker.system.*;import networker.taskbardialog.DefaultSavaPath;import networker.panels.filepane.*;import networker.about.*;public class MainFrame extends JFrame implements ActionListener,ItemListener{ClassLoader load=getClass().getClassLoader();String Name,IP;//菜单栏JMenuBar MBar=new JMenuBar();JMenu FileMenu=new JMenu("文件"),SetMenu=new JMenu("设置"),SkinMenu=new JMenu("皮肤"),HelpMenu=new JMenu("帮助");JMenuItem[] items={ new JMenuItem("传送文件"),new JMenuItem("传送文件夹"),new JMenuItem("隐藏窗口"),new JMenuItem("退出程序"),new JMenuItem("扫描用户"),new JMenuItem("更改信息"),new JMenuItem("添加好友"),new JMenuItem("帮助"),new JMenuItem("关于此软件"),new JMenuItem("设置默认存取目录"),new JMenuItem("Java相关网站")};JRadioButtonMenuItem[] skinitems={ new JRadioButtonMenuItem("蓝色主题"), new JRadioButtonMenuItem("黑色主题"),new JRadioButtonMenuItem("苹果主题"),new JRadioButtonMenuItem("绿色主题") }; ButtonGroup bgroup=new ButtonGroup();//图标。