仿QQ聊天软件及源码java版

2020年02月12日 阅读数:210
这篇文章主要向大家介绍仿QQ聊天软件及源码java版,主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。

 

仿QQ聊天软件及源码java版

分类: 实战   1664人阅读  评论(21)  收藏  举报

一直以来,不少java的同志们都没有一个完整资料来参考。把源码贴出来,你们共享!html

  1. import java.awt.BorderLayout;  
  2. import java.awt.Component;  
  3. import java.awt.Dialog;  
  4. import java.awt.Dimension;  
  5. import java.awt.FlowLayout;  
  6. import java.awt.GridBagConstraints;  
  7. import java.awt.GridBagLayout;  
  8. import java.awt.GridLayout;  
  9. import java.awt.Image;  
  10. import java.awt.Insets;  
  11. import java.awt.MenuItem;  
  12. import java.awt.PopupMenu;  
  13. import java.awt.Rectangle;  
  14. import java.awt.SystemTray;  
  15. import java.awt.Toolkit;  
  16. import java.awt.TrayIcon;  
  17. import java.awt.TrayIcon.MessageType;  
  18. import java.awt.event.ActionEvent;  
  19. import java.awt.event.ActionListener;  
  20. import java.awt.event.ComponentAdapter;  
  21. import java.awt.event.ComponentEvent;  
  22. import java.awt.event.MouseAdapter;  
  23. import java.awt.event.MouseEvent;  
  24. import java.awt.event.WindowAdapter;  
  25. import java.awt.event.WindowEvent;  
  26. import java.io.File;  
  27. import java.io.FileInputStream;  
  28. import java.io.FileNotFoundException;  
  29. import java.io.FileOutputStream;  
  30. import java.io.IOException;  
  31. import java.net.DatagramPacket;  
  32. import java.net.DatagramSocket;  
  33. import java.net.InetAddress;  
  34. import java.net.SocketException;  
  35. import java.net.UnknownHostException;  
  36. import java.util.Date;  
  37. import java.util.Scanner;  
  38. import java.util.Stack;  
  39. import java.util.prefs.Preferences;  
  40.   
  41. import javax.swing.BoxLayout;  
  42. import javax.swing.ImageIcon;  
  43. import javax.swing.JButton;  
  44. import javax.swing.JDialog;  
  45. import javax.swing.JFrame;  
  46. import javax.swing.JLabel;  
  47. import javax.swing.JList;  
  48. import javax.swing.JMenuItem;  
  49. import javax.swing.JOptionPane;  
  50. import javax.swing.JPanel;  
  51. import javax.swing.JPasswordField;  
  52. import javax.swing.JPopupMenu;  
  53. import javax.swing.JProgressBar;  
  54. import javax.swing.JScrollPane;  
  55. import javax.swing.JTabbedPane;  
  56. import javax.swing.JTextField;  
  57. import javax.swing.JToggleButton;  
  58. import javax.swing.ScrollPaneConstants;  
  59. import javax.swing.SwingConstants;  
  60. import javax.swing.UIManager;  
  61. import javax.swing.border.BevelBorder;  
  62. import javax.swing.border.Border;  
  63. import javax.swing.border.EmptyBorder;  
  64. import javax.swing.border.TitledBorder;  
  65. import javax.swing.tree.DefaultMutableTreeNode;  
  66. import javax.swing.tree.DefaultTreeModel;  
  67. import javax.swing.tree.TreePath;  
  68.   
  69.   
  70. public class EQ extends JDialog{  
  71.     private JTextField ipEndTField;  
  72.     private JTextField ipStartTField;  
  73.     private JTextField userNameTField;//用户框  
  74.     private JPasswordField passwordTField;//密码框  
  75.     private JTextField placardPathTField;//placard:公告  
  76.     private JTextField updatePathTField;//更新路径  
  77.     private JTextField pubPathTField;  
  78.     public static EQ frame = null;  
  79.     private ChatTree chatTree;  
  80.     private JPopupMenu popupMenu;//右键菜单  
  81.     private JTabbedPane tabbedPane;//分页面板  
  82.     private JToggleButton searchUserButton;//搜索用户按钮  
  83.     private JProgressBar progressBar;//滚动条  
  84.     private JList faceList;  
  85.     private JButton selectInterfaceOKButton;  
  86.     private DatagramSocket ss;//数据报插座  
  87.     private final JLabel stateLabel;  
  88.     private static String user_dir;  
  89.     private static File localFile;  
  90.     private static File netFile;  
  91.     private String netFilePath;  
  92.     private JButton messageAlertButton;  
  93.     private Stack<String> messageStack;////Stack 类表示后进先出(LIFO)的对象堆栈。  
  94.     private ImageIcon messageAlertIcon;  
  95.     private ImageIcon messageAlertNullIcon;  
  96.     private Rectangle location;  
  97.     public static TrayIcon trayicon;  
  98.     private Dao dao;  
  99.     //Preferences.systeRoot:返回系统的根首选项节点   Preferences:参数选择  
  100.     public final static Preferences preferences = Preferences.systemRoot();  
  101.     private JButton userInfoButton;  
  102.     //----------------------------------------------------------------------------------  
  103.     public static void main(String[] args){  
  104.         try{  
  105.             String laf = preferences.get("lookAndFeel""java默认");  
  106.             if(laf.indexOf("当前系统") > -1){  
  107.                 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());  
  108.             }  
  109.             EQ frame = new EQ();  
  110.             frame.setVisible(true);  
  111.             frame.SystemTrayInitial();// 初始化系统栏  
  112.             frame.server();  
  113.             frame.checkPlacard();  
  114.         }catch(Exception e){  
  115.             e.printStackTrace();  
  116.         }  
  117.     }  
  118.     //----------------------------------------------------------------------------------  
  119.     public EQ(){  
  120.         super(new JFrame());  
  121.         frame = this;  
  122.         dao = Dao.getDao();  
  123.         location = dao.getLocation();  
  124.         setTitle("EQ聊天");  
  125.         setBounds(location);  
  126.         progressBar = new JProgressBar();  
  127.         //BevelBorder:该类实现简单的双线斜面边框。Bevel:斜面     lowered:凹入斜面类型。  
  128.         progressBar.setBorder(new BevelBorder(BevelBorder.LOWERED));  
  129.         tabbedPane = new JTabbedPane();  
  130.         popupMenu = new JPopupMenu();  
  131.         chatTree = new ChatTree(this);  
  132.         user_dir = System.getProperty("user.dir");// 程序执行路径用于系统更新  
  133.         localFile = new File(user_dir + File.separator + "EQ.jar");// 本地EQ文件  
  134.         stateLabel = new JLabel();// 状态栏标签  
  135.         this.addWindowListener(new FrameWindowListener());// 添加窗体监视器  
  136.         this.addComponentListener(new ComponentAdapter(){  
  137.             public void componentResized(final ComponentEvent e){  
  138.                 saveLocation();  
  139.             }  
  140.             public void componentMoved(final ComponentEvent e){  
  141.                 saveLocation();  
  142.             }  
  143.         });  
  144.         try{// 启动通信服务端口  
  145.             ss = new DatagramSocket(1111);  
  146.         }catch(SocketException e2){  
  147.             if(e2.getMessage().startsWith("Address already in use")){  
  148.                 showMessageDialog("服务端口被占用,或者本软件已经运行。");  
  149.             }  
  150.             System.exit(0);  
  151.         }  
  152.         {// 初始化公共信息按钮  
  153.             messageAlertIcon = new ImageIcon(EQ.class.getResource("/image/messageAlert.gif"));  
  154.             messageAlertNullIcon = new ImageIcon(EQ.class.getResource("/image/messageAlertNull20.gif"));  
  155.             messageStack = new Stack<String>();  
  156.             messageAlertButton = new JButton();  
  157.             messageAlertButton.setHorizontalAlignment(SwingConstants.RIGHT);  
  158.             messageAlertButton.setContentAreaFilled(false);//不填充内容区域  
  159.             final JPanel BannerPanel = new JPanel();  
  160.             BannerPanel.setLayout(new BorderLayout());  
  161.             this.add(BannerPanel,BorderLayout.NORTH);  
  162.             userInfoButton = new JButton();  
  163.             BannerPanel.add(userInfoButton,BorderLayout.WEST);  
  164.             userInfoButton.setMargin(new Insets(0,0,0,10));//Margin:边距    insets:插入   
  165.             initUserInfoButton();// 初始化本地用户头像按钮  
  166.             BannerPanel.add(messageAlertButton,BorderLayout.CENTER);  
  167.             messageAlertButton.addActionListener(new ActionListener(){  
  168.   
  169.                 @Override  
  170.                 public void actionPerformed(ActionEvent arg0) {  
  171.                     if(!messageStack.empty()){  
  172.                         showMessageDialog(messageStack.pop());//堆栈顶部的对象(Vector 对象中的最后一项)。   
  173.                     }  
  174.                 }  
  175.             });  
  176.             messageAlertButton.setIcon(messageAlertIcon);  
  177.             showMessageBar();  
  178.         }  
  179.         this.add(tabbedPane,BorderLayout.CENTER);  
  180.         tabbedPane.setTabPlacement(SwingConstants.LEFT);//设置此选项卡窗格的选项卡布局  
  181.         ImageIcon userTicon = new ImageIcon(EQ.class.getResource("/image/tabIcon/tabLeft.PNG"));  
  182.         tabbedPane.addTab(null,userTicon,createUserList(),"用户列表");  
  183.         ImageIcon sysOTicon = new ImageIcon(EQ.class.getResource("/image/tabIcon/tabLeft2.PNG"));  
  184.         tabbedPane.addTab(null, sysOTicon, createSysToolPanel(), "系统操做");  
  185.         ImageIcon sysSTicon = new ImageIcon(EQ.class.getResource("/image/tabIcon/tabLeft3.png"));  
  186.         tabbedPane.addTab(null, sysSTicon, createSysSetPanel(), "系统设置");  
  187.         this.setAlwaysOnTop(true);//总在顶部  
  188.     }  
  189.     //----------------------------------------------------------------------------------  
  190.     private JScrollPane createSysSetPanel(){//系统设置面板  
  191.         final JPanel sysSetPanel = new JPanel();  
  192.         JScrollPane scrollPane = new JScrollPane(sysSetPanel);  
  193.         sysSetPanel.setLayout(new BoxLayout(sysSetPanel,BoxLayout.Y_AXIS));  
  194.         scrollPane.setBorder(new EmptyBorder(0,0,0,0));  
  195.         final JPanel sysPathPanel = new JPanel();  
  196.         sysPathPanel.setMaximumSize(new Dimension(600,200));  
  197.         sysPathPanel.setBorder(new TitledBorder("系统路径"));//title - 边框应显示的标题  
  198.         sysPathPanel.setLayout(new GridLayout(0,1));  
  199.         sysSetPanel.add(sysPathPanel);  
  200.         sysPathPanel.add(new JLabel("程序升级路径"));  
  201.         updatePathTField = new JTextField(preferences.get("updatePath""请输入路径"));  
  202.         sysPathPanel.add(updatePathTField);  
  203.         sysPathPanel.add(new JLabel("系统公告路径:"));  
  204.         placardPathTField = new JTextField(preferences.get("placardPath","请输入路径"));  
  205.         sysPathPanel.add(placardPathTField);  
  206.         sysPathPanel.add(new JLabel("公共程序路径:"));  
  207.         pubPathTField = new JTextField(preferences.get("pubPath""请输入路径"));  
  208.         sysPathPanel.add(pubPathTField);  
  209.         final JButton pathOKButton = new JButton("肯定");  
  210.         pathOKButton.setActionCommand("sysOK");  
  211.         pathOKButton.addActionListener(new SysSetPanelOKListener());  
  212.         sysSetPanel.add(pathOKButton);  
  213.         final JPanel loginPanel = new JPanel();  
  214.         loginPanel.setMaximumSize(new Dimension(60090));  
  215.         loginPanel.setBorder(new TitledBorder("登陆升级服务器"));  
  216.         final GridLayout gridLayout_1 = new GridLayout(01);  
  217.         gridLayout_1.setVgap(5);  
  218.         loginPanel.setLayout(gridLayout_1);  
  219.         sysSetPanel.add(loginPanel);  
  220.         final JPanel panel_7 = new JPanel();  
  221.         panel_7.setLayout(new BoxLayout(panel_7, BoxLayout.X_AXIS));  
  222.         loginPanel.add(panel_7);  
  223.         panel_7.add(new JLabel("用户名:"));  
  224.         userNameTField = new JTextField(preferences.get("username""请输入用户名"));  
  225.         panel_7.add(userNameTField);  
  226.         final JPanel panel_8 = new JPanel();  
  227.         panel_8.setLayout(new BoxLayout(panel_8, BoxLayout.X_AXIS));  
  228.         loginPanel.add(panel_8);  
  229.         panel_8.add(new JLabel("密 码:"));  
  230.         passwordTField = new JPasswordField("*****");  
  231.         panel_8.add(passwordTField);  
  232.         final JButton loginOKButton = new JButton("肯定");  
  233.         sysSetPanel.add(loginOKButton);  
  234.         loginOKButton.setActionCommand("loginOK");  
  235.         loginOKButton.addActionListener(new SysSetPanelOKListener());  
  236.         final JPanel ipPanel = new JPanel();  
  237.         final GridLayout gridLayout_2 = new GridLayout(01);  
  238.         gridLayout_2.setVgap(5);  
  239.         ipPanel.setLayout(gridLayout_2);  
  240.         ipPanel.setMaximumSize(new Dimension(60090));  
  241.         ipPanel.setBorder(new TitledBorder("IP搜索范围"));  
  242.         sysSetPanel.add(ipPanel);  
  243.         final JPanel panel_5 = new JPanel();  
  244.         panel_5.setLayout(new BoxLayout(panel_5, BoxLayout.X_AXIS));  
  245.         ipPanel.add(panel_5);  
  246.         panel_5.add(new JLabel("起始IP:"));  
  247.         ipStartTField = new JTextField(preferences.get("ipStart""192.168.0.1"));  
  248.         panel_5.add(ipStartTField);  
  249.         final JPanel panel_6 = new JPanel();  
  250.         panel_6.setLayout(new BoxLayout(panel_6, BoxLayout.X_AXIS));  
  251.         ipPanel.add(panel_6);  
  252.         panel_6.add(new JLabel("终止IP:"));  
  253.         ipEndTField = new JTextField(preferences.get("ipEnd""192.168.1.255"));  
  254.         panel_6.add(ipEndTField);  
  255.         final JButton ipOKButton = new JButton("肯定");  
  256.         ipOKButton.setActionCommand("ipOK");  
  257.         ipOKButton.addActionListener(new SysSetPanelOKListener());  
  258.         sysSetPanel.add(ipOKButton);  
  259.         return scrollPane;  
  260.     }  
  261.     //----------------------------------------------------------------------------------  
  262.     private JScrollPane createUserList(){// 用户列表面板  
  263.         JScrollPane scrollPane = new JScrollPane();  
  264.         scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);  
  265.         addUserPopup(chatTree,getPopupMenu());// 为用户添加弹出菜单  
  266.         scrollPane.setViewportView(chatTree);  
  267.         scrollPane.setBorder(new EmptyBorder(0,0,0,0));  
  268.         chatTree.addMouseListener(new ChatTreeMouseListener());  
  269.           
  270.         return scrollPane;  
  271.     }  
  272.     //----------------------------------------------------------------------------------  
  273.     private JScrollPane createSysToolPanel() {// 系统工具面板  
  274.         JPanel sysToolPanel = new JPanel(); // 系统工具面板  
  275.         sysToolPanel.setLayout(new BorderLayout());  
  276.         JScrollPane sysToolScrollPanel = new JScrollPane();  
  277.         sysToolScrollPanel  
  278.                 .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);  
  279.         sysToolScrollPanel.setBorder(new EmptyBorder(0000));  
  280.         sysToolScrollPanel.setViewportView(sysToolPanel);  
  281.         sysToolPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));  
  282.         JPanel interfacePanel = new JPanel();  
  283.         sysToolPanel.add(interfacePanel, BorderLayout.NORTH);  
  284.         interfacePanel.setLayout(new BorderLayout());  
  285.         interfacePanel.setBorder(new TitledBorder("界面选择-再次启动生效"));  
  286.         faceList = new JList(new String[]{"当前系统""java默认"});  
  287.         interfacePanel.add(faceList);  
  288.         faceList.setBorder(new BevelBorder(BevelBorder.LOWERED));  
  289.         final JPanel interfaceSubPanel = new JPanel();  
  290.         interfaceSubPanel.setLayout(new FlowLayout());  
  291.         interfacePanel.add(interfaceSubPanel, BorderLayout.SOUTH);  
  292.         selectInterfaceOKButton = new JButton("肯定");  
  293.         selectInterfaceOKButton.addActionListener(new ActionListener() {  
  294.             public void actionPerformed(ActionEvent e) {  
  295.                 preferences.put("lookAndFeel", faceList.getSelectedValue().toString());  
  296.                 JOptionPane.showMessageDialog(EQ.this"从新运行本软件后生效");  
  297.             }  
  298.         });  
  299.         interfaceSubPanel.add(selectInterfaceOKButton);  
  300.   
  301.         JPanel searchUserPanel = new JPanel(); // 用户搜索面板  
  302.         sysToolPanel.add(searchUserPanel);  
  303.         searchUserPanel.setLayout(new BorderLayout());  
  304.         final JPanel searchControlPanel = new JPanel();  
  305.         searchControlPanel.setLayout(new GridLayout(01));  
  306.         searchUserPanel.add(searchControlPanel, BorderLayout.SOUTH);  
  307.         final JList searchUserList = new JList(new String[]{"检测用户列表"});// 新添加用户列表  
  308.         final JScrollPane scrollPane_2 = new JScrollPane(searchUserList);  
  309.         scrollPane_2.setDoubleBuffered(true);  
  310.         searchUserPanel.add(scrollPane_2);  
  311.         searchUserList.setBorder(new BevelBorder(BevelBorder.LOWERED));  
  312.         searchUserButton = new JToggleButton();  
  313.         searchUserButton.setText("搜索新用户");  
  314.         searchUserButton.addActionListener(new SearchUserActionListener(searchUserList));  
  315.         searchControlPanel.add(progressBar);  
  316.         searchControlPanel.add(searchUserButton);  
  317.         searchUserPanel.setBorder(new TitledBorder("搜索用户"));  
  318.   
  319.         final JPanel sysUpdatePanel = new JPanel();  
  320.         sysUpdatePanel.setOpaque(false);  
  321.         sysUpdatePanel.setLayout(new GridBagLayout());  
  322.         sysUpdatePanel.setBorder(new TitledBorder("系统操做"));  
  323.         sysToolPanel.add(sysUpdatePanel, BorderLayout.SOUTH);  
  324.         final JButton sysUpdateButton = new JButton("系统更新");  
  325.         final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints();  
  326.         gridBagConstraints_1.gridx = 0;  
  327.         gridBagConstraints_1.gridy = 0;  
  328.         sysUpdatePanel.add(sysUpdateButton, gridBagConstraints_1);  
  329.         sysUpdateButton.addActionListener(new SysUpdateListener());// 添加系统更新事件  
  330.         final JLabel updateLabel = new JLabel("最近更新:");  
  331.         final GridBagConstraints updateLabelLayout = new GridBagConstraints();  
  332.         updateLabelLayout.gridy = 1;  
  333.         updateLabelLayout.gridx = 0;  
  334.         sysUpdatePanel.add(updateLabel, updateLabelLayout);  
  335.         final JLabel updateDateLabel = new JLabel();// 程序更新日期标签  
  336.         Date date = new Date(localFile.lastModified());  
  337.         String dateStr = String.format("%tF %<tr", date);  
  338.         updateDateLabel.setText(dateStr);  
  339.         final GridBagConstraints updateDateLayout = new GridBagConstraints();  
  340.         updateDateLayout.gridy = 2;  
  341.         updateDateLayout.gridx = 0;  
  342.         sysUpdatePanel.add(updateDateLabel, updateDateLayout);  
  343.         final JLabel updateStaticLabel = new JLabel("更新状态:");  
  344.         final GridBagConstraints updateStaticLayout = new GridBagConstraints();  
  345.         updateStaticLayout.gridy = 3;  
  346.         updateStaticLayout.gridx = 0;  
  347.         sysUpdatePanel.add(updateStaticLabel, updateStaticLayout);  
  348.         final JLabel updateInfoLabel = new JLabel();// 版本信息标签  
  349.         checkSysInfo(updateInfoLabel);// 调用检测版本更新的方法  
  350.         final GridBagConstraints gridBagConstraints_5 = new GridBagConstraints();  
  351.         gridBagConstraints_5.gridy = 4;  
  352.         gridBagConstraints_5.gridx = 0;  
  353.         sysUpdatePanel.add(updateInfoLabel, gridBagConstraints_5);  
  354.         JPanel statePanel = new JPanel();  
  355.         add(statePanel, BorderLayout.SOUTH);  
  356.         statePanel.setLayout(new BorderLayout());  
  357.         statePanel.add(stateLabel);  
  358.         stateLabel.setText("总人数:" + chatTree.getRowCount());  
  359.         return sysToolScrollPanel;  
  360.     }  
  361.     //----------------------------------------------------------------------------------  
  362.     private void initUserInfoButton(){  
  363.         try{  
  364.             String ip = InetAddress.getLocalHost().getHostAddress();  
  365.             User user = dao.getUser(ip);  
  366.             userInfoButton.setIcon(user.getIconImg());  
  367.             userInfoButton.setText(user.getName());  
  368.             userInfoButton.setIconTextGap(JLabel.RIGHT);  
  369.             userInfoButton.setToolTipText(user.getTipText());  
  370.             userInfoButton.getParent().doLayout();  
  371.         }catch(UnknownHostException e1){  
  372.             e1.printStackTrace();  
  373.         }  
  374.     }  
  375.     //----------------------------------------------------------------------------------  
  376.     private void showMessageBar(){// 显示公告信息按钮的线程  
  377.         new Thread(new Runnable() {  
  378.             public void run() {  
  379.                 while (true) {  
  380.                     if (!messageStack.empty()) {  
  381.                         try {  
  382.                             messageAlertButton.setIcon(messageAlertNullIcon);  
  383.                             messageAlertButton.setPreferredSize(new Dimension(2020));  
  384.                             Thread.sleep(500);  
  385.                             messageAlertButton.setIcon(messageAlertIcon);  
  386.                             Thread.sleep(500);  
  387.                         } catch (InterruptedException e) {  
  388.                             e.printStackTrace();  
  389.                         }  
  390.                     } else {  
  391.                         try {  
  392.                             Thread.sleep(3000);  
  393.                         } catch (InterruptedException e) {  
  394.                             e.printStackTrace();  
  395.                         }  
  396.                     }  
  397.                 }  
  398.             }  
  399.         }).start();  
  400.     }  
  401.     //----------------------------------------------------------------------------------  
  402.     private void checkSysInfo(final JLabel updateInfo){  
  403.         new Thread(new Runnable(){  
  404.             public void run(){  
  405.                 String info = "";  
  406.                 while(true){  
  407.                     try{  
  408.                         netFilePath = preferences.get("updatePath""EQ.jar");  
  409.                         if(netFilePath.equals("EQ.jar")){  
  410.                             info = "<html><center><font color=red><b>没法登陆</b><br>未设置升级路径</font></center></html>";  
  411.                             updateInfo.setText(info);  
  412.                             continue;  
  413.                         }  
  414.                         netFile = new File(netFilePath);  
  415.                         if(netFile.exists()){  
  416.                             Date netDate = new Date(netFile.lastModified());  
  417.                             if(!localFile.exists()){  
  418.                                 info = "<html><font color=blue>本地程序位置出错!</font></html>";  
  419.                             }else{  
  420.                                 Date localDate = new Date(localFile.lastModified());  
  421.                                 if(netDate.after(localDate)){  
  422.                                     info = "<html><font color=blue>网络上有最新程序!</font></html>";  
  423.                                     pushMessage(info);  
  424.                                 }else{  
  425.                                     info = "<html><font color=green>如今是最新程序!</font></html>";  
  426.                                 }  
  427.                             }  
  428.                         }else{  
  429.                             info = "<html><center><font color=red><b>没法访问</b><br>升级路径</font></center></html>";  
  430.                         }  
  431.                         updateInfo.setText(info);  
  432.                         Thread.sleep(5*1000);  
  433.                     }catch(InterruptedException e){  
  434.                         e.printStackTrace();  
  435.                     }  
  436.                 }  
  437.             }  
  438.         }).start();  
  439.     }  
  440.     //----------------------------------------------------------------------------------  
  441.     class SearchUserActionListener implements ActionListener{  
  442.         private final JList list;  
  443.         SearchUserActionListener(JList list){  
  444.             this.list = list;  
  445.         }  
  446.   
  447.         @Override  
  448.         public void actionPerformed(ActionEvent e) {  
  449.             // TODO Auto-generated method stub  
  450.             if(searchUserButton.isSelected()){  
  451.                 searchUserButton.setText("中止搜索");  
  452.                 new Thread(new Runnable(){  
  453.                     public void run(){  
  454.                         Resource.searchUsers(chatTree, progressBar,list, searchUserButton);  
  455.                     }  
  456.                 }).start();  
  457.             }else{  
  458.                 searchUserButton.setText("搜索新用户");  
  459.             }  
  460.               
  461.         }  
  462.     }  
  463.     //----------------------------------------------------------------------------------  
  464.     class SysSetPanelOKListener implements ActionListener{  
  465.   
  466.         @Override