




下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、服務器端代碼:import .*;import .*;import .*;import .*;public class Serverprivate static final int PORT=6666;G_Menu gm=new G_Menu();private ServerSocket server;public ArrayList<PrintWriter> list;public static String user;public static ArrayList<User> list1=new ArrayList<User>();");whi
2、le(true) Socket client=();etServer();class Chat implements RunnableSocket socket;private BufferedReader br;private String msg;private String mssg=""public Chat(Socket socket) try=socket;catch(Exception ex) ();public void run()trybr=new BufferedReader(new InputStreamReader(); while(msg=()!=
3、null) if("1008611")plit(":");quals()+"("+()+")")etOutputStream();quals ()etOutputStream();quals(si0)lose();import .*;import .*;import class Socket_one;import .*;import .*;import Landen extends Frame implements ActionListener JFrame jf=new JFrame(" 聊天登陸&qu
4、ot;);JPanel jp1=new JPanel();JPanel jp2=new JPanel();JPanel jp3=new JPanel();JPanel jp4=new JPanel();JLabel jl1=new JLabel("姓名:"JLabel jl2=new JLabel("地址:"JLabel jl3=new JLabel("端口:"JRadioButton jrb1=new JRadioButton("男生");JRadioButton jrb2=new JRadioButton(&q
5、uot;女生");JRadioButton jrb3=new JRadioButton("保密");public JTextField jtf1=new JTextField(10);public JTextField jtf2=new JTextField(10);public JTextField jtf3=new JTextField(10);JButton jb1=new JButton("連接");JButton jb2=new JButton("斷開");TitledBorder tb=new TitledBor
6、der("");ButtonGroup gb=new ButtonGroup();public void init()quals(" 斷開 ")(0);if().equals(" 連接 ")if().equals("")(null," 請輸入用戶名!");else if(!()&&!()&&!()(null," 請選擇性別!");else(false);if()s1="boy"else if()s1="girl&q
7、uot;else if()s1="secret"G_Menu gmu=new G_Menu();(),s1);();public class Loginpublic static void main(String args)new Landen().init();主界面代碼:import .*;import .*;import .*;import .*;class G_Menu extends JFrame implements ActionListener JFrame jf=new JFrame(" 聊天室 ");public Socket_one
8、soc;public PrintWriter pw;public JPanel jp1=new JPanel();public JPanel jp2=new JPanel();public JPanel jp3=new JPanel();public JPanel jp4=new JPanel();public JPanel jp5=new JPanel();public JPanel jp6=new JPanel();public JPanel jp7=new JPanel();public static JTextArea jta1=new JTextArea(12,42);public
9、static JTextArea jta2=new JTextArea(12,42);public JLabel jl1=new JLabel(" 對 ");public static JComboBox jcomb=new JComboBox();public JCheckBox jcb=new JCheckBox(" 私聊 ");public JTextField jtf=new JTextField(36);public JButton jb1=new JButton("發(fā)送>>");public JButton j
10、b2=new JButton("刷新");public static DefaultListModel listModel1;public static JList lst1;public String na;public String se;public String message;public voidgetMenu(String name,String sex)quals(" 發(fā)送 >>")quals("") if() String name1=(String)();message="悄悄話"+
11、na+"("+se+")"+"X"+name1+"說:"+();("4");quals(" 刷新 ");import .*;import .*;class User用戶姓名用戶性別用戶自己的socketprivate String name;/private String sex;/private Socket sock;/ public User(String name,String sex,Socket sock) setName(name);setSex(sex);setSock(sock);public String getName()return name;public void setName(String name)=name;pub
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 合股開餐廳合同范本
- 衛(wèi)生清潔合同范本
- 勞務派遣合同范本2003
- 個人供貨客戶合同范本
- 合股認購合同范本
- 合伙協(xié)議書范本合同范本
- 叉車工聘用合同范本
- 員工合同范例送水
- 傳單兼職人員合同范本
- 劇組財務合同范本
- 2024年河南省鄭州市中原區(qū)小升初數(shù)學試卷
- 基于街區(qū)尺度的精細化大氣污染溯源模型建設需求
- 德育教育研究課題申報書
- 2024年岳陽職業(yè)技術學院單招職業(yè)適應性測試題庫匯編
- (高清版)JTG 3810-2017 公路工程建設項目造價文件管理導則
- 《ISO31000:2024風險管理指南》指導手冊(雷澤佳譯2024-04)
- 普通高中英語課程標準試題與答案(2017年版2020年修訂)
- DB3502-Z 5010-2018海綿城市建設工程施工與質量驗收標準
- 2024年內蒙古巴彥淖爾市交通投資集團有限公司招聘筆試參考題庫含答案解析
- 春季行車安全行駛安全知識培訓
- 2024年甘肅省公務員公共基礎知識重點考試題庫(含答案)
評論
0/150
提交評論