欢迎来到天天文库
浏览记录
ID:44355331
大小:202.43 KB
页数:21页
时间:2019-10-21
《多人通讯管理程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、WeChartServer:User.java:packagebean;/****@authorLD**/publicclassUser{privateStringname;//nameprivateStringip;//ippublicUser(Stringname,Stringip){this,name=name;this.ip=ip;}publicUser(Stringname){this,name=name;}publicStringgetName(){returnname;}publicvoidsetName(Stringname){this,name=nam
2、e;}publicStringgetlp(){returnip;}publicvoidsetlp(Stringip){this.ip=ip;}}Server.java:packageserver;importjava.awt.Dimension;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;im
3、portjava.io.BufferedReader;importjava.io」OException;importjava.io」nputStreamReader;importjava.io.PrintWriter;importjava.net.BindException;importjava.net」netAddress;importjava.net.ServerSocket;importjava.net.Socket;importjava.util.ArrayList;importjava.util.List;importjava.util.StringToken
4、izer;importjavax.swing」Button;importjavax.swirame;importjavax.swing」Label;importjavax.swing」OptionPane;importjavax.swing」Panel;importjavax.swing.JTextField;importutil.Util;importbean.User;/****@authorLD**/publicclassServer{privatefinalStringDEFAULT_PORT=,,8080H;privatefinalintF_WIDTH=300
5、;privatefinalintF_HEIGHT=155;privatefinalStringMESSAGE_TAG=,,@u;privatefinalStringCOMMAND_TAG=privatefinalStringADD_USER="ADD_USER";privatefinalStringONLINE_USERS="ONLINE_USERSn;privatefinalStringDELETE_USER=“DELETEJJSER”;privateJButtonbtn_start;privateJButtonbtn_stop;privateJTextFieldtx
6、t_port;privateJFramef;//thestatusissuccesswhentheserverstart!isServerStart;isAllowRun;serverSocket;serverThread;privatebooleanprivatebooleanprivateServerSocketprivateThreadprivateListdients;publicServer(){createServerGUI();}/***main*@paramargs*/publicstaticvoidmain(String[]
7、args){newServer));}/***startserver*@paramport*@throwsBindException*/publicvoidstartServer(intport)throwsBindException,lOException,HlegalArgumentException{try{serverSocket=newServerSocket(port);Stringserverip=lnetAddress.getLocalHost().getHostAddress();f.setTitle「服务器地址:“+s
此文档下载收益归作者所有