資源簡介
多媒體展示系統 –網絡游魚
安裝JDK、配置環境變量,打開Eclipse導入ch04項目,運行server.FishServer類啟動服務器端,運行
java client.SwimFish類啟動客戶端。注意,同時在多臺機上運行客戶端才能顯示出網絡游魚的效果,在同
一臺機上打開多個客戶端窗口不能看到該效果。
代碼片段和文件信息
package?client;
import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.*;
public?class?AboutDialog?extends?Dialog?implements?ActionListener{
????private?Button?okay?=?new?Button(“ok“);
????private?Label?label1?=?new?Label(“Swimming?Fish?with?Network?1.0“);
????private?Label?label2?=?new?Label(“Author:huanghao“);
????private?Label?label3?=?new?Label(“2007(C)All?Right?Reserved.“);
????public?boolean?isOkay?=?false;
????public?class?WindowCloser?extends?WindowAdapter{
???????????public?void?windowClosing(WindowEvent?we){
???????????????AboutDialog.this.isOkay?=?false;
???????????????AboutDialog.this.hide();
???????????????}
????}
????public?AboutDialog(Jframe?parent){
?????this(parent“About“);
?????}
????public?AboutDialog(Jframe?parentString?title){
??????super(parenttitletrue);
??????Panel?labels?=?new?Panel();
??????labels.setLayout(new?GridLayout(31));
??????labels.add(label1);
??????labels.add(label2);
??????labels.add(label3);
??????Panel?buttons?=?new?Panel();
??????buttons.setLayout(new?FlowLayout());
??????buttons.add(okay);
??????setLayout(new?BorderLayout());
??????add(“Center“labels);
??????add(“South“buttons);
??????okay.addActionListener(this);
??????addWindowListener(new?WindowCloser());
??????setResizable(false);
??????pack();
??????show();
??????}
??????public?void?actionPerformed(ActionEvent?ae){
??????isOkay?=?(ae.getSource()?==?okay);
??????hide();
??????}
}
- 上一篇:一個簡單的java網絡蜘蛛程序,非常適合初學者
- 下一篇:jpcap 64位
評論
共有 條評論