*/
public void startServer() throws IOException{ } /**
* 停止服务器。
* @throws IOException IO异常。 */
public void stopServer() throws IOException{ }
isServiceRun = false;
Enumeration
table.clear();table=null; if(server!=null)
server.close(); server = null;
writeSysLog(DateDeal.getCurrentTime()+\服务器服务停止成功!\
ClientLink client = en.nextElement();
client.updateUserState(client.jqnum, UserState.OFFLIENSTATE.getState()); client.letClientQuit(); isServiceRun = true;
int port = Integer.parseInt(Server.prop.getProperty(GetParameter.keys[0])); table = new Hashtable
writeSysLog(DateDeal.getCurrentTime()+\服务器服务启动成功!等待JQ用户上线...\
2.用户管理功能
用户管理就是对系统注册用户信息的管理,可以查找、删除、修改相关内容,实质上就是通过JDBC对数据库的操作。这个面板中使用了JTable对象以实现对数据库表的加载显示。
功能实现如图5-7所示:
26
图5-7 用户管理图
关键代码如下: /**
* 用户管理面板类。 */
public class UserPane extends JPanel implements ActionListener,Runnable{
/** 查询JQ用户 */
private JLabel lblQuery = new JLabel(\查询JQ用户\/** 输入的查询的关键字 */
private JTextField txtQuery = new JTextField(\/** 查询的类型 */
private JComboBox boxQuery = new JComboBox(); /** 查询 */
private JButton btnQuery = new JButton(\查询\/** 添加新用户 */
private JButton btnAddNew = new JButton(\添加新用户\/** 刷新重新获得所有用户 */
27
private JButton btnFlash = new JButton(\刷新\/** 显示用户的表格 */ private JTable table = null; /** 表格的模型 */
private DefaultTableModel model = null; /** 状态栏 */
private JLabel lblInfo = new JLabel(\共有JQ用户:0\private JPopupMenu popupMenu = new JPopupMenu(); private JMenuItem itemChange = new JMenuItem(\修改\private JMenuItem itemDelete = new JMenuItem(\删除\public UserPane() { }
init();
btnAddNew.addActionListener(this); btnFlash.addActionListener(this); btnQuery.addActionListener(this);
5.1.5 其他功能实现
本系统除了以上四大主要功能之外,还具有其他一些功能。 1.系统消息功能
管理员可以在服务器端发送广播系统消息,在线用户均可在客户端接收到系统消息。具体实现如图5-8和5-9所示:
图5-8 发送广播系统消息
28
图5-9 用户接收系统消息
2.查找及添加好友功能
点击客户端好友列表下方“查找”按钮,即可进入查找功能界面(如图5-10)。然后通过设置查询条件来查找用户,点击查找后,系统会自动弹出查询的结果(如图5-11)。最后选中你想要添加的用户,点击加为好友按钮即可完成添加好友(如图5-12)。
29
图5-10 查找功能界面
图5-11 查找结果
30