資源簡(jiǎn)介
java實(shí)現(xiàn)的類似qq的聊天系統(tǒng),并且對(duì)數(shù)據(jù)進(jìn)行了加密,包含網(wǎng)絡(luò)安全相關(guān)的知識(shí)??梢宰鳛楫厴I(yè)設(shè)計(jì)。

代碼片段和文件信息
package?chat.client;
import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.*;
import?java.io.*;
import?java.net.*;
/**
?*聊天室客戶端主程序
?*這是運(yùn)行聊天室客戶端程序的入口
?*/
public?class?Client?implements?ActionListener{
private?LogonPane?logonPane;//登錄界面
private?ClientModel?client;//客戶端數(shù)據(jù)模型
private?ClientUI?clientUI;//客戶端聊天界面
private?JButton?enterButtonexitButton;//登錄按鈕
/**
?*登錄容器,本程序的設(shè)計(jì)是將登錄窗口和聊天窗口分別采用兩個(gè)Jframe盛放
?*當(dāng)?shù)卿洺晒r(shí),登錄窗口隱藏,顯示聊天容器,當(dāng)意外斷開連接時(shí),再次顯示
?*登錄窗口以便重新登錄。所以有必要設(shè)置一個(gè)logonframe指針。
?*/
private?Jframe?logonframe;
/**
?*構(gòu)造方法,用于創(chuàng)建登錄界面
?*
?*
?*/
public?Client()?{
logonframe=new?Jframe(“登錄“);
//將登錄界面各元素加入登錄窗口
Container?contentPane=logonframe.getContentPane();
logonPane=new?LogonPane();
enterButton=new?JButton(“登錄“);
exitButton=new?JButton(“退出“);
logonPane.setRelatedButton(enterButton);
enterButton.addActionListener(this);
exitButton.addActionListener(this);
JPanel?controlPane=new?JPanel();
controlPane.add(enterButton);
controlPane.add(exitButton);
contentPane.add(logonPaneBorderLayout.CENTER);
contentPane.add(controlPaneBorderLayout.SOUTH);
}
/**
?*?Method?main
?*
?*
?*?@param?args
?*
?*/
public?static?void?main(String[]?args)?{
//?TODO:?在這添加你的代碼
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception?e){
e.printStackTrace();
}
createAndShowGUI();
}
/**
?*按鈕事件處理
?*此事件源包括“登錄“、“退出“兩個(gè)按鈕。
?*/
public?void?actionPerformed(ActionEvent?e)?{
//?“登錄“按鈕的事件處理,此過(guò)程包括連接服務(wù)器,創(chuàng)建聊天界面以及各種異常處理
if(e.getSource()==enterButton){
String?ip=logonPane.getIP();
String?name=logonPane.getName();
int?port;
try{
port=logonPane.getPort();
}catch(NumberFormatException?ne){//非數(shù)字字符在端口一欄
JOptionPane.showMessageDialog(logonframene.getMessage());
return;
}
try{
client=new?ClientModel(ipport);
}catch(java.net.UnknownHostException?ue){//ip地址出錯(cuò)
JOptionPane.showMessageDialog(logonframe“不可知的服務(wù)器:“+ue.getMessage());
return;
}catch(IOException?ie){
JOptionPane.showMessageDialog(logonframe“服務(wù)器未打開!請(qǐng)打開服務(wù)器后重試!“);
return;
}
boolean?valid;
try{
valid=client.validate(name);
}catch(IOException?ie){
JOptionPane.showMessageDialog(logonframe“服務(wù)器連接已滿,請(qǐng)稍后重試!“);
return;
}
if(!valid){
JOptionPane.showMessageDialog(logonframe“無(wú)效或已經(jīng)被使用的名字:“+name);
return;
}else{
clientUI=new?ClientUI(client){
protected?void?doWhenStop(){
JOptionPane.showMessageDialog(clientUI“與服務(wù)器的連接中斷,請(qǐng)重新登錄?!埃?
clientUI.dispose();
logonframe.setVisible(true);
}
};
clientUI.settitle(client.name+“?的聊天室“);
clientUI.setDefaultCloseOperation(Jframe.DO_NOTHING_ON_CLOSE);
clientUI.setLocationRelativeTo(logonframe);
clientUI.setVisible(true);
client.start();
logonframe.dispose();
}
}else?if(e.getSource()==exitButton){
System.exit(1);
}
}
/**
?*
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????301??2013-06-26?18:37??WebSecurity\.classpath
?????文件????????387??2013-06-24?19:22??WebSecurity\.project
?????文件????????598??2013-06-24?19:22??WebSecurity\.settings\org.eclipse.jdt.core.prefs
?????文件???????1089??2013-06-26?18:37??WebSecurity\bin\chat\client\Client$1.class
?????文件???????4621??2013-06-26?18:37??WebSecurity\bin\chat\client\Client.class
?????文件????????874??2013-06-27?21:48??WebSecurity\bin\chat\client\ClientModel$1.class
?????文件???????5671??2013-06-27?21:48??WebSecurity\bin\chat\client\ClientModel.class
?????文件????????807??2013-06-27?21:57??WebSecurity\bin\chat\client\ClientUI$1.class
?????文件???????1991??2013-06-27?21:57??WebSecurity\bin\chat\client\ClientUI$2.class
?????文件???????1067??2013-06-27?21:57??WebSecurity\bin\chat\client\ClientUI$CellRenderer.class
?????文件??????13679??2013-06-27?21:57??WebSecurity\bin\chat\client\ClientUI.class
?????文件???????2381??2013-06-27?21:35??WebSecurity\bin\chat\client\EditToolBar$PictureFilter.class
?????文件???????1201??2013-06-27?21:35??WebSecurity\bin\chat\client\EditToolBar$st
?????文件???????8809??2013-06-27?21:35??WebSecurity\bin\chat\client\EditToolBar.class
?????文件???????2730??2013-06-26?18:37??WebSecurity\bin\chat\client\LogonPane.class
?????文件???????6689??2013-06-27?21:52??WebSecurity\bin\chat\client\PrivateClient.class
?????文件???????3603??2013-06-26?18:37??WebSecurity\bin\chat\client\PrivateClientModel.class
?????文件???????5221??2013-06-27?20:49??WebSecurity\bin\chat\secret\ba
?????文件???????3830??2013-06-28?08:36??WebSecurity\bin\chat\secret\DES.class
?????文件???????2301??2013-06-27?19:40??WebSecurity\bin\chat\secret\KeyGenerater.class
?????文件???????3137??2013-06-26?22:59??WebSecurity\bin\chat\secret\RSA.class
?????文件???????1629??2013-06-28?08:32??WebSecurity\bin\chat\secret\Signaturer.class
?????文件???????1782??2013-06-26?18:37??WebSecurity\bin\chat\secret\SignProvider.class
?????文件????????635??2013-06-26?18:37??WebSecurity\bin\chat\server\Server$1.class
?????文件???????1416??2013-06-26?18:37??WebSecurity\bin\chat\server\Server$2.class
?????文件???????1579??2013-06-26?18:37??WebSecurity\bin\chat\server\Server$3.class
?????文件???????1234??2013-06-26?18:37??WebSecurity\bin\chat\server\Server$4.class
?????文件???????1795??2013-06-26?18:37??WebSecurity\bin\chat\server\Server$InfoFormatter.class
?????文件???????2828??2013-06-26?18:37??WebSecurity\bin\chat\server\Server$TextPaneHandler.class
?????文件???????8403??2013-06-26?18:37??WebSecurity\bin\chat\server\Server.class
............此處省略65個(gè)文件信息
- 上一篇:圍欄檢測(cè) java版
- 下一篇:asp.net 主題
評(píng)論
共有 條評(píng)論