欢迎来到天天文库
浏览记录
ID:14320963
大小:103.50 KB
页数:22页
时间:2018-07-27
《java五子棋源代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、java五子棋源代码chessClient.java:客户端主程序。chessInterface.java:客户端的界面。chessPad.java:棋盘的绘制。chessServer.java:服务器端。可同时容纳50个人同时在线下棋,聊天。没有加上详细注释,不过绝对可以运行,j2sdk1.4下通过。Java培训/*********************************************************************************************1.chessClient.java****************************
2、******************************************************************/importjava.awt.*;importjava.awt.event.*;importjava.io.*;importjava.net.*;importjava.util.*;classclientThreadextendsThread{chessClientchessclient;clientThread(chessClientchessclient){this.chessclient=chessclient;}publicvoidacceptMes
3、sage(StringrecMessage){if(recMessage.startsWith("/userlist")){StringTokenizeruserToken=newStringTokenizer(recMessage,"");intuserNumber=0;chessclient.userpad.userList.removeAll();chessclient.inputpad.userChoice.removeAll();chessclient.inputpad.userChoice.addItem("所有人");while(userToken.hasMoreTokens
4、()){Stringuser=(String)userToken.nextToken("");if(userNumber>0&&!user.startsWith("[inchess]")){chessclient.userpad.userList.add(user);chessclient.inputpad.userChoice.addItem(user);}userNumber++;}chessclient.inputpad.userChoice.select("所有人");}elseif(recMessage.startsWith("/yourname")){chessclient.c
5、hessClientName=recMessage.substring(10);chessclient.setTitle("Java五子棋客户端"+"用户名:"+chessclient.chessClientName);}elseif(recMessage.equals("/reject")){try{chessclient.chesspad.statusText.setText("不能加入游戏");chessclient.controlpad.cancelGameButton.setEnabled(false);chessclient.controlpad.joinGameButton.
6、setEnabled(true);chessclient.controlpad.creatGameButton.setEnabled(true);}catch(Exceptionef){chessclient.chatpad.chatLineArea.setText("chessclient.chesspad.chessSocket.close无法关闭");}chessclient.controlpad.joinGameButton.setEnabled(true);}elseif(recMessage.startsWith("/peer")){chessclient.chesspad.c
7、hessPeerName=recMessage.substring(6);if(chessclient.isServer){chessclient.chesspad.chessColor=1;chessclient.chesspad.isMouseEnabled=true;chessclient.chesspad.statusText.setText("请黑棋下子");}elseif(chessclient.isClie
此文档下载收益归作者所有