资源简介
多媒体展示系统 –网络游鱼
安装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();
}
}
评论
共有 条评论