myQQ客户端
Socket socket; ClientReceive.java P8 ObjectOutputStream output;//网络套接
字输出流 ConnectConf.java P9 ObjectInputStream input;//网络套接字输
入流 Help.java P11 ClientReceive recvThread;//建立菜单栏
JMenuBar jMenuBar = new JMenuBar(); UserConf.java P12 //建立菜单组
JMenu operateMenu = new JMenu ("操ChatClient.java 作(O)");
import java.awt.*; //建立菜单项
import java.awt.event.*; JMenuItem loginItem = new JMenuItem import javax.swing.*; ("用户登录(I)");
import javax.swing.event.*; JMenuItem logoffItem = new JMenuItem import java.io.*; ("用户注销(L)");
import java.net.*; JMenuItem exitItem=new JMenuItem ("/* 退出(X)");
* 聊天客户端的主框架类 JMenu conMenu=new JMenu ("设置
*/ (C)");
public class ChatClient extends JFrame JMenuItem userItem=new JMenuItem ("implements ActionListener{ 用户设置(U)");
String ip = "127.0.0.1";//连接到服务端 JMenuItem connectItem=new 的ip地址 JMenuItem ("连接设置(C)");
int port = 8888;//连接到服务端的端口 JMenu helpMenu=new JMenu ("帮助
号 (H)");
String userName = "匆匆过客";//用户名 JMenuItem helpItem=new JMenuItem ("
int type = 0;//0表示未连接,1表示已连帮助(H)");
接 //建立工具栏
Image icon;//程序图标 JToolBar toolBar = new JToolBar();
JComboBox combobox;//选择发送消息 //建立工具栏中的按钮组件
的接受者 JButton loginButton;//用户登录
JTextArea messageShow;//客户端的信 JButton logoffButton;//用户注销
息显示 JButton userButton;//用户信息的设置
JScrollPane messageScrollPane;//信息显 JButton connectButton;//连接设置
示的滚动条 JButton exitButton;//退出按钮
JLabel //框架的大小
express,sendToLabel,messageLabel ; Dimension faceSize = new
JTextField clientMessage;//客户端消息Dimension(400, 600);
的发送 JPanel downPanel ;
JCheckBox checkbox;//悄悄话 GridBagLayout girdBag;
JComboBox actionlist;//表情选择 GridBagConstraints girdBagCon;
JButton clientMessageButton;//发送消息
JTextField showStatus;//显示用户连接 public ChatClient(){ 状态 init();//初始化程序
1
//添加框架的关闭事件处理 userItem.setMnemonic ('U');
this.setDefaultCloseOperation(JFrame.E userItem.setAccelerator XIT_ON_CLOSE); (KeyStroke.getKeyStroke
this.pack(); (KeyEvent.VK_U,InputEvent.CTRL_MASK)
//设置框架的大小 );
this.setSize(faceSize); //为连接设置设置快捷键为ctrl+c
//设置运行时窗口的位置 connectItem.setMnemonic ('C');
Dimension screenSize = connectItem.setAccelerator Toolkit.getDefaultToolkit().getScreenSize(); (KeyStroke.getKeyStroke
this.setLocation( (int) (KeyEvent.VK_C,InputEvent.CTRL_MASK))(screenSize.width - faceSize.getWidth()) / 2, ;
(int) //为帮助菜单栏设置热键'H'
(screenSize.height - faceSize.getHeight()) / 2); helpMenu.setMnemonic('H');
this.setResizable(false); //为帮助设置快捷键为ctrl+p
this.setTitle("聊天室客户端"); //设 helpItem.setMnemonic ('H'); 置标题 helpItem.setAccelerator
(KeyStroke.getKeyStroke
//程序图标 (KeyEvent.VK_H,InputEvent.CTRL_MASK)
icon = getImage("icon.gif"); );
this.setIconImage(icon); //设置程序 }
图标 /**
show(); * 程序初始化函数
//为操作菜单栏设置热键'V' */
operateMenu.setMnemonic('O'); public void init(){
//为用户登录设置快捷键为ctrl+i Container contentPane =
loginItem.setMnemonic ('I'); getContentPane();
loginItem.setAccelerator contentPane.setLayout(new (KeyStroke.getKeyStroke BorderLayout());
(KeyEvent.VK_I,InputEvent.CTRL_MASK)); //添加菜单栏
//为用户注销快捷键为ctrl+l operateMenu.add (loginItem);
logoffItem.setMnemonic ('L'); operateMenu.add (logoffItem);
logoffItem.setAccelerator operateMenu.add (exitItem); (KeyStroke.getKeyStroke jMenuBar.add (operateMenu); (KeyEvent.VK_L,InputEvent.CTRL_MASK)) conMenu.add (userItem); ; conMenu.add (connectItem);
//为退出快捷键为ctrl+x jMenuBar.add (conMenu);
exitItem.setMnemonic ('X'); helpMenu.add (helpItem);
exitItem.setAccelerator jMenuBar.add (helpMenu); (KeyStroke.getKeyStroke setJMenuBar (jMenuBar); (KeyEvent.VK_X,InputEvent.CTRL_MASK) //初始化按钮
); loginButton = new JButton("登录");
//为设置菜单栏设置热键'C' logoffButton = new JButton("注销
conMenu.setMnemonic('C'); ");
//为用户设置设置快捷键为ctrl+u userButton = new JButton("用户
2
设置" ); logoffItem.addActionListener(this);
connectButton = new JButton("连 exitItem.addActionListener(this); 接设置" ); userItem.addActionListener(this);
exitButton = new JButton("退出" );
//当鼠标放上显示信息 connectItem.addActionListener(this);
loginButton.setToolTipText("连接 helpItem.addActionListener(this); 到指定的服务器");
logoffButton.setToolTipText("与服 //添加按钮的事件侦听
务器断开连接");
userButton.setToolTipText("设置用 loginButton.addActionListener(this); 户信息");
connectButton.setToolTipText("设 logoffButton.addActionListener(this); 置所要连接到的服务器信息"); userButton.addActionListener(this);
//将按钮添加到工具栏
toolBar.add(userButton); connectButton.addActionListener(this);
toolBar.add(connectButton); exitButton.addActionListener(this);
toolBar.addSeparator();//添加分隔
栏 combobox = new JComboBox();
toolBar.add(loginButton); combobox.insertItemAt("所有人
toolBar.add(logoffButton); ",0);
toolBar.addSeparator();//添加分隔 combobox.setSelectedIndex(0); 栏
toolBar.add(exitButton); messageShow = new JTextArea();
messageShow.setEditable(false);
contentPane.add(toolBar,BorderLayout.N //添加滚动条
ORTH); messageScrollPane = new
JScrollPane(messageShow,
checkbox = new JCheckBox("悄悄
话"); JScrollPane.VERTICAL_SCROLLBAR_
checkbox.setSelected(false); AS_NEEDED,
actionlist = new JComboBox(); JScrollPane.HORIZONTAL_SCROLLB
actionlist.addItem("微笑地"); AR_AS_NEEDED);
actionlist.addItem("高兴地"); messageScrollPane.setPreferredSize(new
actionlist.addItem("轻轻地"); Dimension(400,400));
actionlist.addItem("生气地"); messageScrollPane.revalidate();
actionlist.addItem("小心地"); clientMessage = new
actionlist.addItem("静静地"); JTextField(23);
actionlist.setSelectedIndex(0); clientMessage.setEnabled(false);
//初始时 clientMessageButton = new
loginButton.setEnabled(true); JButton();
logoffButton.setEnabled(false); clientMessageButton.setText("发送
//为菜单栏添加事件监听 ");
loginItem.addActionListener(this);
3
//添加系统消息的事件侦听 girdBagCon = new
GridBagConstraints();
clientMessage.addActionListener(this); girdBagCon.gridx =1;
girdBagCon.gridy = 2;
clientMessageButton.addActionListener(t girdBagCon.anchor = his); GridBagConstraints.LINE_START;
sendToLabel = new JLabel("发送 girdBag.setConstraints(combobox,girdBa
至:"); gCon);
express = new JLabel(" downPanel.add(combobox); 表情: ");
messageLabel = new JLabel("发送 girdBagCon = new 消息:"); GridBagConstraints();
downPanel = new JPanel(); girdBagCon.gridx =2;
girdBag = new GridBagLayout(); girdBagCon.gridy = 2;
downPanel.setLayout(girdBag); girdBagCon.anchor =
GridBagConstraints.LINE_END;
girdBagCon = new
GridBagConstraints(); girdBag.setConstraints(express,girdBagC
girdBagCon.gridx = 0; on);
girdBagCon.gridy = 0; downPanel.add(express);
girdBagCon.gridwidth = 5;
girdBagCon.gridheight = 2; girdBagCon = new
girdBagCon.ipadx = 5; GridBagConstraints();
girdBagCon.ipady = 5; girdBagCon.gridx = 3;
JLabel none = new JLabel(" "); girdBagCon.gridy = 2;
girdBagCon.anchor =
girdBag.setConstraints(none,girdBagConGridBagConstraints.LINE_START; ); //girdBagCon.insets = new
downPanel.add(none); Insets(1,0,0,0);
//girdBagCon.ipadx = 5;
girdBagCon = new //girdBagCon.ipady = 5; GridBagConstraints();
girdBagCon.gridx = 0; girdBag.setConstraints(actionlist,girdBag
girdBagCon.gridy = 2; Con);
girdBagCon.insets = new downPanel.add(actionlist); Insets(1,0,0,0);
//girdBagCon.ipadx = 5; girdBagCon = new
//girdBagCon.ipady = 5; GridBagConstraints();
girdBagCon.gridx = 4;
girdBag.setConstraints(sendToLabel,gird girdBagCon.gridy = 2; BagCon); girdBagCon.insets = new
downPanel.add(sendToLabel); Insets(1,0,0,0);
//girdBagCon.ipadx = 5;
4
//girdBagCon.ipady = 5; girdBag.setConstraints(showStatus,girdB
agCon);
girdBag.setConstraints(checkbox,girdBa downPanel.add(showStatus); gCon);
downPanel.add(checkbox);
contentPane.add(messageScrollPane,Bor
girdBagCon = new derLayout.CENTER);
GridBagConstraints();
girdBagCon.gridx = 0; contentPane.add(downPanel,BorderLayo
girdBagCon.gridy = 3; ut.SOUTH);
girdBag.setConstraints(messageLabel,gir //关闭程序时的操作
dBagCon); this.addWindowListener(
downPanel.add(messageLabel); new WindowAdapter(){
public void
girdBagCon = new windowClosing(WindowEvent e){ GridBagConstraints(); if(type == 1){
girdBagCon.gridx = 1; DisConnect();
girdBagCon.gridy = 3; }
girdBagCon.gridwidth = 3; System.exit(0);
girdBagCon.gridheight = 1; }
}
girdBag.setConstraints(clientMessage,gir );
dBagCon); }
downPanel.add(clientMessage);
/**
girdBagCon = new * 事件处理
GridBagConstraints(); */
girdBagCon.gridx = 4; public void
girdBagCon.gridy = 3; actionPerformed(ActionEvent e) {
Object obj = e.getSource();
girdBag.setConstraints(clientMessageBut
ton,girdBagCon); if (obj == userItem || obj ==
userButton) { //用户信息设置
downPanel.add(clientMessageButton); //调出用户信息设置对话框
UserConf userConf = new
showStatus = new JTextField(35); UserConf(this,userName);
showStatus.setEditable(false); userConf.show();
girdBagCon = new userName =
GridBagConstraints(); userConf.userInputName;
girdBagCon.gridx = 0; }
girdBagCon.gridy = 5; else if (obj == connectItem || obj ==
girdBagCon.gridwidth = 5; connectButton) { //连接服务端设置
//调出连接设置对话框
5
ConnectConf conConf = new }
ConnectConf(this,ip,port); }
conConf.show();
ip = conConf.userInputIp;
port = conConf.userInputPort; public void Connect(){
} try{
else if (obj == loginItem || obj == socket = new Socket(ip,port); loginButton) { //登录 }
Connect(); catch (Exception e){
}
else if (obj == logoffItem || obj == JOptionPane.showConfirmDialog( logoffButton) { //注销 this,"不能连接到指定的
DisConnect(); 服务器。\n请确认连接设置是否正确。","
showStatus.setText(""); 提示",
}
else if (obj == clientMessage || obj JOptionPane.DEFAULT_OPTION,JOpti== clientMessageButton) { //发送消息 onPane.WARNING_MESSAGE);
SendMessage(); return;
clientMessage.setText(""); }
}
else if (obj == exitButton || obj == try{
exitItem) { //退出 output = new
int ObjectOutputStream(socket.getOutputStream(j=JOptionPane.showConfirmDialog( ));
this,"真的要退出吗?","退 output.flush();
出", input = new
ObjectInputStream(socket.getInputStream() );
JOptionPane.YES_OPTION,JOptionPan
e.QUESTION_MESSAGE); output.writeObject(userName);
output.flush();
if (j ==
JOptionPane.YES_OPTION){ recvThread = new
if(type == 1){ ClientReceive(socket,output,input,combobox,
DisConnect(); messageShow,showStatus);
} recvThread.start();
System.exit(0);
} loginButton.setEnabled(false);
} loginItem.setEnabled(false);
else if (obj == helpItem) { //菜单栏 userButton.setEnabled(false); 中的帮助 userItem.setEnabled(false);
//调出帮助对话框
Help helpDialog = new connectButton.setEnabled(false); Help(this); connectItem.setEnabled(false);
helpDialog.show(); logoffButton.setEnabled(true);
6
logoffItem.setEnabled(true);
public void SendMessage(){
clientMessage.setEnabled(true); String toSomebody =
messageShow.append("连接服combobox.getSelectedItem().toString(); 务器 "+ip+":"+port+" 成功...\n"); String status = "";
type = 1;//标志位设为已连接 if(checkbox.isSelected()){
} status = "悄悄话";
catch (Exception e){ }
System.out.println(e);
return; String action =
} actionlist.getSelectedItem().toString();
} String message =
clientMessage.getText();
public void DisConnect(){
loginButton.setEnabled(true); if(socket.isClosed()){
loginItem.setEnabled(true); return ;
userButton.setEnabled(true); }
userItem.setEnabled(true);
connectButton.setEnabled(true); try{
connectItem.setEnabled(true); output.writeObject("聊天信息
logoffButton.setEnabled(false); ");
logoffItem.setEnabled(false); output.flush();
clientMessage.setEnabled(false);
output.writeObject(toSomebody);
if(socket.isClosed()){ output.flush();
return ; output.writeObject(status);
} output.flush();
output.writeObject(action);
try{ output.flush();
output.writeObject("用户下线 output.writeObject(message); "); output.flush();
output.flush(); }
catch (Exception e){
input.close(); //
output.close(); }
socket.close(); }
messageShow.append("已经与
服务器断开连接...\n"); /**
type = 0;//标志位设为未连接 * 通过给定的文件名获得图像
} */
catch (Exception e){ Image getImage(String filename) {
// URLClassLoader urlLoader =
} (URLClassLoader)this.getClass().
} getClassLoader();
7
URL url = null;
Image image = null; public ClientReceive(Socket
url = socket,ObjectOutputStream output, urlLoader.findResource(filename); ObjectInputStream
image = input,JComboBox combobox,JTextArea Toolkit.getDefaultToolkit().getImage(url); textarea,JTextField showStatus){
MediaTracker mediatracker = new
MediaTracker(this); this.socket = socket;
try { this.output = output;
mediatracker.addImage(image, this.input = input; 0); this.combobox = combobox;
mediatracker.waitForID(0); this.textarea = textarea;
} this.showStatus = showStatus;
catch (InterruptedException _ex) { }
image = null;
} public void run(){
if (mediatracker.isErrorID(0)) { while(!socket.isClosed()){
image = null; try{
} String type =
(String)input.readObject();
return image;
}
if(type.equalsIgnoreCase("系统信息")){
public static void main(String[] args) { String sysmsg =
ChatClient app = new ChatClient(); (String)input.readObject();
} textarea.append("系
} 统信息: "+sysmsg);
} ClientReceive.java else
import javax.swing.*; if(type.equalsIgnoreCase("服务关闭")){ import java.io.*; output.close(); import java.net.*; input.close();
socket.close(); /*
* 聊天客户端消息收发类 textarea.append("服
*/ 务器已关闭~\n");
public class ClientReceive extends Thread {
private JComboBox combobox; break;
private JTextArea textarea; }
else
Socket socket; if(type.equalsIgnoreCase("聊天信息")){
ObjectOutputStream output; String message =
ObjectInputStream input; (String)input.readObject();
JTextField showStatus;
8
textarea.append(message); public class ConnectConf extends JDialog {
} JPanel panelUserConf = new JPanel();
else JButton save = new JButton(); if(type.equalsIgnoreCase("用户列表")){ JButton cancel = new JButton();
String userlist = JLabel DLGINFO=new JLabel( (String)input.readObject(); " 默认连接设
String usernames[] = 置为 127.0.0.1:8888");
userlist.split("\n");
JPanel panelSave = new JPanel();
combobox.removeAllItems(); JLabel message = new JLabel();
int i =0; String userInputIp;
combobox.addItem(" int userInputPort;
所有人");
while(i < JTextField inputIp;
usernames.length){ JTextField inputPort;
combobox.addItem(usernames[i]); public ConnectConf(JFrame frame,String
i ++; ip,int port) {
} super(frame, true);
this.userInputIp = ip;
combobox.setSelectedIndex(0); this.userInputPort = port;
showStatus.setText(" try {
在线用户 " + usernames.length + " 人"); jbInit();
} }
} catch (Exception e) {
catch (Exception e ){ e.printStackTrace();
System.out.println(e); }
} //设置运行位置,使对话框居中
} Dimension screenSize =
} Toolkit.getDefaultToolkit().getScreenSize();
} this.setLocation( (int)
(screenSize.width - 400) / 2 + 50, ConnectConf.java (int)
import java.awt.*; (screenSize.height - 600) / 2 + 150); import javax.swing.border.*; this.setResizable(false); import java.net.*; }
import javax.swing.*;
import java.awt.event.*; private void jbInit() throws Exception {
this.setSize(new Dimension(300, /** 130));
* 生成连接信息输入的对话框 this.setTitle("连接设置");
* 让用户输入连接服务器的IP和端口 message.setText(" 请输入服务器的
*/ IP地址:");
9
inputIp = new JTextField(10); + InetAddress.getByName(inputIp.getText());
inputIp.setText(userInputIp); userInputIp =
inputPort = new JTextField(4); userInputIp.substring(1);
inputPort.setText(""+userInputPort); }
save.setText("保存");
cancel.setText("取消"); catch(UnknownHostException e){
panelUserConf.setLayout(new DLGINFO.setText( GridLayout(2,2,1,1)); "
panelUserConf.add(message); 错误的IP地址~");
panelUserConf.add(inputIp);
panelUserConf.add(new JLabel(" return;
请输入服务器的端口号:")); }
panelUserConf.add(inputPort); //userInputIp =
inputIP;
panelSave.add(new Label("
")); //判断端口号是否合
panelSave.add(save); 法
panelSave.add(cancel); try{
panelSave.add(new Label(" savePort = ")); Integer.parseInt(inputPort.getText());
Container contentPane = if(savePort<1 || getContentPane(); savePort>65535){
contentPane.setLayout(new
BorderLayout()); DLGINFO.setText(" 侦
contentPane.add(panelUserConf, 听端口必须是0-65535之间的整数!"); BorderLayout.NORTH);
contentPane.add(DLGINFO, inputPort.setText(""); BorderLayout.CENTER); return;
contentPane.add(panelSave, }
BorderLayout.SOUTH); userInputPort =
savePort;
//保存按钮的事件处理 dispose();
save.addActionListener( }
new ActionListener() {
public void catch(NumberFormatException e){ actionPerformed (ActionEvent a) {
int savePort; DLGINFO.setText("
String inputIP; 错误的端口号,端口号请填写整数!");
//判断端口号是否合
法 inputPort.setText("");
try{ return;
userInputIp = "" }
10
}
} JButton close = new JButton();
); JLabel title = new JLabel("聊天室客户
端帮助");
//关闭对话框时的操作 JTextArea help = new JTextArea();
this.addWindowListener(
new WindowAdapter(){ Color bg = new Color(255,255,255);
public void
windowClosing(WindowEvent e){ public Help(JFrame frame) {
DLGINFO.setText(" super(frame, true); 默认连接设置为 127.0.0.1:8888"); try {
} jbInit();
} }
); catch (Exception e) {
//取消按钮的事件处理 e.printStackTrace();
cancel.addActionListener( }
new ActionListener(){ //设置运行位置,使对话框居中
public void Dimension screenSize = actionPerformed(ActionEvent e){ Toolkit.getDefaultToolkit().getScreenSize();
DLGINFO.setText(" this.setLocation( (int) 默认连接设置为 127.0.0.1:8888"); (screenSize.width - 400) / 2 + 25,
dispose(); (int)
} (screenSize.height - 320) / 2);
} this.setResizable(false);
); }
}
} private void jbInit() throws Exception {
this.setSize(new Dimension(350, Help.java 270));
import java.awt.*; this.setTitle("帮助");
import javax.swing.border.*;
import java.net.*; titlePanel.setBackground(bg);; import javax.swing.*; contentPanel.setBackground(bg); import java.awt.event.*; closePanel.setBackground(bg);
help.setText("1、设置所要连接服务
/** 端的IP地址和端口"+
* 生成设置对话框的类 "(默认设置为\n
*/ 127.0.0.1:8888)。\n"+
public class Help extends JDialog { "2、输入你的用户名(默认设
置为:匆匆过客)。\n"+
JPanel titlePanel = new JPanel(); "3、点击“登录”便可以连接
JPanel contentPanel = new JPanel(); 到指定的服务器;\n"+
JPanel closePanel = new JPanel(); " 点击“注销”可以和
11
服务器端开连接。\n"+ UserConf.java "4、选择需要接受消息的用
户,在消息栏中写入消息,\n"+ import java.awt.*;
" 同时选择表情,之后import javax.swing.border.*; 便可发送消息。\n"); import java.net.*;
help.setEditable(false); import javax.swing.*;
import java.awt.event.*;
titlePanel.add(new Label("
")); /**
titlePanel.add(title); * 生成用户信息输入对话框的类
titlePanel.add(new Label(" * 让用户输入自己的用户名
")); */
public class UserConf extends JDialog {
contentPanel.add(help); JPanel panelUserConf = new JPanel();
JButton save = new JButton();
closePanel.add(new Label(" JButton cancel = new JButton(); ")); JLabel DLGINFO=new JLabel(
closePanel.add(close); " 默
closePanel.add(new Label(" 认用户名为:匆匆过客");
"));
JPanel panelSave = new JPanel();
Container contentPane = JLabel message = new JLabel(); getContentPane(); String userInputName;
contentPane.setLayout(new
BorderLayout()); JTextField userName ;
contentPane.add(titlePanel,
BorderLayout.NORTH); public UserConf(JFrame frame,String str)
contentPane.add(contentPanel, {
BorderLayout.CENTER); super(frame, true);
contentPane.add(closePanel, this.userInputName = str; BorderLayout.SOUTH); try {
jbInit();
close.setText("关闭"); }
//事件处理 catch (Exception e) {
close.addActionListener( e.printStackTrace();
new ActionListener() { }
public void //设置运行位置,使对话框居中
actionPerformed(ActionEvent e) { Dimension screenSize =
dispose(); Toolkit.getDefaultToolkit().getScreenSize();
} this.setLocation( (int)
} (screenSize.width - 400) / 2 + 50,
); (int)
} (screenSize.height - 600) / 2 + 150); } this.setResizable(false);
12
} 用户名不能为空~");
private void jbInit() throws Exception { userName.setText(userInputName);
this.setSize(new Dimension(300, return;
120)); }
this.setTitle("用户设置"); else
message.setText("请输入用户名:"); if(userName.getText().length() > 15){
userName = new JTextField(10);
userName.setText(userInputName); DLGINFO.setText("
save.setText("保存"); 用户名长度不能大于15个字符~");
cancel.setText("取消");
userName.setText(userInputName);
panelUserConf.setLayout(new return;
FlowLayout()); }
panelUserConf.add(message); userInputName =
panelUserConf.add(userName); userName.getText();
dispose();
panelSave.add(new Label(" }
")); }
panelSave.add(save); );
panelSave.add(cancel);
panelSave.add(new Label(" //关闭对话框时的操作
")); this.addWindowListener(
new WindowAdapter(){
Container contentPane = public void
getContentPane(); windowClosing(WindowEvent e){
contentPane.setLayout(new DLGINFO.setText("
BorderLayout()); 默认用户名为:匆匆过客");
contentPane.add(panelUserConf, }
BorderLayout.NORTH); }
contentPane.add(DLGINFO, );
BorderLayout.CENTER);
contentPane.add(panelSave, //取消按钮的事件处理
BorderLayout.SOUTH); cancel.addActionListener(
new ActionListener(){
//保存按钮的事件处理 public void
save.addActionListener( actionPerformed(ActionEvent e){
new ActionListener() { DLGINFO.setText("
public void 默认用户名为:匆匆过客");
actionPerformed (ActionEvent a) { dispose();
}
if(userName.getText().equals("")){ }
);
DLGINFO.setText( " }
13
}
14