|
@@ -8,7 +8,7 @@ import javax.swing.*;
|
|
|
|
|
|
//////////*服务器窗口类*///////////////
|
|
|
public class ServerFrame extends JFrame implements ActionListener {
|
|
|
- public JList list;
|
|
|
+ public JList list;
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
@@ -17,11 +17,9 @@ public class ServerFrame extends JFrame implements ActionListener {
|
|
|
// 服务器信息面板
|
|
|
JPanel pnlServer, pnlServerInfo;
|
|
|
|
|
|
- JLabel lblStatus, lblNumber, lblMax, lblServerName, lblProtocol, lblIP,
|
|
|
- lblPort, lblLog;
|
|
|
+ JLabel lblStatus, lblNumber, lblMax, lblServerName, lblProtocol, lblIP, lblPort, lblLog;
|
|
|
|
|
|
- public JTextField txtStatus, txtNumber, txtMax, txtServerName, txtProtocol, txtIP,
|
|
|
- txtPort;
|
|
|
+ public JTextField txtStatus, txtNumber, txtMax, txtServerName, txtProtocol, txtIP, txtPort;
|
|
|
|
|
|
JButton btnStop, btnSaveLog;
|
|
|
|
|
@@ -43,8 +41,8 @@ public class ServerFrame extends JFrame implements ActionListener {
|
|
|
JTextField txtNotice;
|
|
|
|
|
|
JButton btnSend, btnKick;
|
|
|
-
|
|
|
- public String serverMessage ="";
|
|
|
+
|
|
|
+ public String serverMessage = "";
|
|
|
|
|
|
public ServerFrame() {
|
|
|
// 服务器窗口
|
|
@@ -60,225 +58,223 @@ public class ServerFrame extends JFrame implements ActionListener {
|
|
|
if (fra.height > scr.height) {
|
|
|
fra.height = scr.height;
|
|
|
}
|
|
|
- this.setLocation((scr.width - fra.width) / 2,
|
|
|
- (scr.height - fra.height) / 2);
|
|
|
-
|
|
|
- //服务器信息面板
|
|
|
- pnlServer = new JPanel();
|
|
|
- pnlServer.setLayout(null);
|
|
|
- pnlServer.setBackground(new Color(245,245,245));
|
|
|
- //左边表格信息
|
|
|
- pnlServerInfo = new JPanel(new GridLayout(14,1));
|
|
|
- pnlServerInfo.setBackground(Color.decode("#F5F5F5"));
|
|
|
- pnlServerInfo.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- pnlServerInfo.setBorder(BorderFactory.createCompoundBorder(
|
|
|
- BorderFactory.createTitledBorder(""),
|
|
|
- BorderFactory.createEmptyBorder(1,1,1,1)));
|
|
|
- //表格列表
|
|
|
- //第一行
|
|
|
- lblStatus = new JLabel("当前状态:");
|
|
|
- lblStatus.setForeground(Color.decode("#606060"));
|
|
|
- lblStatus.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- //第二行
|
|
|
- txtStatus = new JTextField(10);
|
|
|
- txtStatus.setBackground(Color.WHITE);
|
|
|
- txtStatus.setForeground(Color.decode("#606060"));
|
|
|
- txtStatus.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- txtStatus.setEditable(false);
|
|
|
- //第三行
|
|
|
- lblNumber = new JLabel("当前在线人数:");
|
|
|
- lblNumber.setForeground(Color.decode("#606060"));
|
|
|
- lblNumber.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- //第四行
|
|
|
- txtNumber = new JTextField(10);
|
|
|
- txtNumber.setBackground(Color.WHITE);
|
|
|
- txtNumber.setForeground(Color.decode("#606060"));
|
|
|
- txtNumber.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- txtNumber.setEditable(false);
|
|
|
- //第五行
|
|
|
- lblMax = new JLabel("最多在线人数:");
|
|
|
- lblMax.setForeground(Color.decode("#606060"));
|
|
|
- lblMax.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- //第六行
|
|
|
- txtMax = new JTextField("50 人",10);
|
|
|
- txtMax.setBackground(Color.WHITE);
|
|
|
- txtMax.setForeground(Color.decode("#606060"));
|
|
|
- txtMax.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- txtMax.setEditable(false);
|
|
|
- //第七行
|
|
|
- lblServerName = new JLabel("服务器名称:");
|
|
|
- lblServerName.setForeground(Color.decode("#606060"));
|
|
|
- lblServerName.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- //第八行
|
|
|
- txtServerName = new JTextField(10);
|
|
|
- txtServerName.setBackground(Color.WHITE);
|
|
|
- txtServerName.setForeground(Color.decode("#606060"));
|
|
|
- txtServerName.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- txtServerName.setEditable(false);
|
|
|
- //第九行
|
|
|
- lblProtocol = new JLabel("访问协议:");
|
|
|
- lblProtocol.setForeground(Color.decode("#606060"));
|
|
|
- lblProtocol.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- //第十行
|
|
|
- txtProtocol = new JTextField("HTTP",10);
|
|
|
- txtProtocol.setBackground(Color.WHITE);
|
|
|
- txtProtocol.setForeground(Color.decode("#606060"));
|
|
|
- txtProtocol.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- txtProtocol.setEditable(false);
|
|
|
- //第十一行
|
|
|
- lblIP = new JLabel("服务器IP:");
|
|
|
- lblIP.setForeground(Color.decode("#606060"));
|
|
|
- lblIP.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- //第十二行
|
|
|
- txtIP = new JTextField(10);
|
|
|
- txtIP.setBackground(Color.WHITE);
|
|
|
- txtIP.setForeground(Color.decode("#606060"));
|
|
|
- txtIP.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- txtIP.setEditable(false);
|
|
|
- //第十三行
|
|
|
- lblPort = new JLabel("服务器端口:");
|
|
|
- lblPort.setForeground(Color.decode("#606060"));
|
|
|
- lblPort.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- //第十四行
|
|
|
- txtPort = new JTextField("8000",10);
|
|
|
- txtPort.setBackground(Color.WHITE);
|
|
|
- txtPort.setForeground(Color.decode("#606060"));
|
|
|
- txtPort.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- txtPort.setEditable(false);
|
|
|
- //按钮
|
|
|
- btnStop = new JButton("关闭服务器");
|
|
|
- btnStop.addActionListener(new ActionListener() {
|
|
|
- @Override
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
- closeServer();
|
|
|
- }
|
|
|
- });
|
|
|
- btnStop.setBackground(Color.decode("#F5F5F5"));
|
|
|
- btnStop.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- btnStop.setForeground(Color.decode("606060"));
|
|
|
- //日志
|
|
|
- lblLog = new JLabel("服务器日志");
|
|
|
- lblLog.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- lblLog.setForeground(Color.decode("#606060"));
|
|
|
- taLog = new TextArea(20,50);
|
|
|
- taLog.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
-
|
|
|
- btnSaveLog = new JButton("保存日志");
|
|
|
- btnSaveLog.addActionListener(new ActionListener() {
|
|
|
- @Override
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
- saveLog();
|
|
|
- }
|
|
|
- });
|
|
|
- btnSaveLog.setBackground(Color.decode("#F5F5F5"));
|
|
|
- btnSaveLog.setFont(new Font("Microsoft YaHei",0,12));
|
|
|
- btnSaveLog.setForeground(Color.decode("606060"));
|
|
|
-
|
|
|
- pnlServerInfo.add(lblStatus);
|
|
|
- pnlServerInfo.add(txtStatus);
|
|
|
- pnlServerInfo.add(lblNumber);
|
|
|
- pnlServerInfo.add(txtNumber);
|
|
|
- pnlServerInfo.add(lblMax);
|
|
|
- pnlServerInfo.add(txtMax);
|
|
|
- pnlServerInfo.add(lblServerName);
|
|
|
- pnlServerInfo.add(txtServerName);
|
|
|
- pnlServerInfo.add(lblProtocol);
|
|
|
- pnlServerInfo.add(txtProtocol);
|
|
|
- pnlServerInfo.add(lblIP);
|
|
|
- pnlServerInfo.add(txtIP);
|
|
|
- pnlServerInfo.add(lblPort);
|
|
|
- pnlServerInfo.add(txtPort);
|
|
|
-
|
|
|
- pnlServerInfo.setBounds(5,5,100,400);
|
|
|
- lblLog.setBounds(110, 5, 100, 30);
|
|
|
- taLog.setBounds(110,35,400,370);
|
|
|
- btnStop.setBounds(150,410,120,30);
|
|
|
- btnSaveLog.setBounds(270,410,120,30);
|
|
|
- pnlServer.add(pnlServerInfo);
|
|
|
- pnlServer.add(lblLog);
|
|
|
- pnlServer.add(taLog);
|
|
|
- pnlServer.add(btnStop);
|
|
|
- pnlServer.add(btnSaveLog);
|
|
|
- //用户面板
|
|
|
- pnlUser = new JPanel();
|
|
|
- pnlUser.setLayout(null);
|
|
|
- pnlUser.setBackground(new Color(245,245,245));
|
|
|
- pnlUser.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
-
|
|
|
- lblMessage = new JLabel("用户消息");
|
|
|
- lblMessage.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
- lblMessage.setForeground(Color.decode("#606060"));
|
|
|
- taMessage = new TextArea(20, 20);
|
|
|
- taMessage.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
-
|
|
|
- lblNotice = new JLabel("通知:");
|
|
|
- lblNotice.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
- lblNotice.setForeground(Color.decode("#606060"));
|
|
|
- txtNotice = new JTextField(20);
|
|
|
- txtNotice.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
-
|
|
|
- btnSend = new JButton("发送");
|
|
|
- btnSend.setBackground(Color.decode("#f5f5f5"));
|
|
|
- btnSend.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
- btnSend.setForeground(Color.decode("#606060"));
|
|
|
- btnSend.setEnabled(true);
|
|
|
- btnSend.addActionListener(new ActionListener() {
|
|
|
- public void actionPerformed(ActionEvent arg0) {
|
|
|
- serverMessage();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- lblUserCount = new JLabel("在线总人数 0 人");
|
|
|
- lblUserCount.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
- lblUserCount.setForeground(Color.decode("#606060"));
|
|
|
-
|
|
|
- lblUser = new JLabel("在线用户列表");
|
|
|
- lblUser.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
- lblUser.setForeground(Color.decode("#606060"));
|
|
|
-
|
|
|
- lstUser = new JList();
|
|
|
- lstUser.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
- lstUser.setVisibleRowCount(17);
|
|
|
- lstUser.setFixedCellWidth(180);
|
|
|
- lstUser.setFixedCellHeight(18);
|
|
|
-
|
|
|
- spUser = new JScrollPane();
|
|
|
- spUser.setBackground(Color.decode("#f5f5f5"));
|
|
|
- spUser.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
- spUser.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
|
- spUser.getViewport().setView(lstUser);
|
|
|
-
|
|
|
- lblMessage.setBounds(5, 5, 100, 25);
|
|
|
- taMessage.setBounds(5, 35, 300, 360);
|
|
|
- lblUser.setBounds(310, 5, 100, 25);
|
|
|
- spUser.setBounds(310, 35, 220, 360);
|
|
|
- lblNotice.setBounds(5, 410, 40, 25);
|
|
|
- txtNotice.setBounds(50, 410, 160, 25);
|
|
|
- btnSend.setBounds(210, 410, 80, 25);
|
|
|
- lblUserCount.setBounds(320, 410, 100, 25);
|
|
|
-
|
|
|
- pnlUser.add(lblMessage);
|
|
|
- pnlUser.add(taMessage);
|
|
|
- pnlUser.add(lblUser);
|
|
|
- pnlUser.add(spUser);
|
|
|
-
|
|
|
- list = new JList<>();
|
|
|
- list.setListData(new String[] { "" });
|
|
|
- spUser.setViewportView(list);
|
|
|
- pnlUser.add(lblNotice);
|
|
|
- pnlUser.add(txtNotice);
|
|
|
- pnlUser.add(btnSend);
|
|
|
- pnlUser.add(lblUserCount);
|
|
|
- //主标签面板
|
|
|
- tpServer=new JTabbedPane(JTabbedPane.LEFT);
|
|
|
- tpServer.setBackground(Color.decode("#f5f5f5"));
|
|
|
- tpServer.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
- tpServer.add("服务器管理", pnlServer);
|
|
|
- tpServer.add("用户信息管理", pnlUser);
|
|
|
- this.getContentPane().add(tpServer);
|
|
|
- setVisible(true);
|
|
|
-
|
|
|
+ this.setLocation((scr.width - fra.width) / 2, (scr.height - fra.height) / 2);
|
|
|
+
|
|
|
+ // 服务器信息面板
|
|
|
+ pnlServer = new JPanel();
|
|
|
+ pnlServer.setLayout(null);
|
|
|
+ pnlServer.setBackground(new Color(245, 245, 245));
|
|
|
+ // 左边表格信息
|
|
|
+ pnlServerInfo = new JPanel(new GridLayout(14, 1));
|
|
|
+ pnlServerInfo.setBackground(Color.decode("#F5F5F5"));
|
|
|
+ pnlServerInfo.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ pnlServerInfo.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""),
|
|
|
+ BorderFactory.createEmptyBorder(1, 1, 1, 1)));
|
|
|
+ // 表格列表
|
|
|
+ // 第一行
|
|
|
+ lblStatus = new JLabel("当前状态:");
|
|
|
+ lblStatus.setForeground(Color.decode("#606060"));
|
|
|
+ lblStatus.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ // 第二行
|
|
|
+ txtStatus = new JTextField(10);
|
|
|
+ txtStatus.setBackground(Color.WHITE);
|
|
|
+ txtStatus.setForeground(Color.decode("#606060"));
|
|
|
+ txtStatus.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ txtStatus.setEditable(false);
|
|
|
+ // 第三行
|
|
|
+ lblNumber = new JLabel("当前在线人数:");
|
|
|
+ lblNumber.setForeground(Color.decode("#606060"));
|
|
|
+ lblNumber.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ // 第四行
|
|
|
+ txtNumber = new JTextField(10);
|
|
|
+ txtNumber.setBackground(Color.WHITE);
|
|
|
+ txtNumber.setForeground(Color.decode("#606060"));
|
|
|
+ txtNumber.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ txtNumber.setEditable(false);
|
|
|
+ // 第五行
|
|
|
+ lblMax = new JLabel("最多在线人数:");
|
|
|
+ lblMax.setForeground(Color.decode("#606060"));
|
|
|
+ lblMax.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ // 第六行
|
|
|
+ txtMax = new JTextField("50 人", 10);
|
|
|
+ txtMax.setBackground(Color.WHITE);
|
|
|
+ txtMax.setForeground(Color.decode("#606060"));
|
|
|
+ txtMax.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ txtMax.setEditable(false);
|
|
|
+ // 第七行
|
|
|
+ lblServerName = new JLabel("服务器名称:");
|
|
|
+ lblServerName.setForeground(Color.decode("#606060"));
|
|
|
+ lblServerName.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ // 第八行
|
|
|
+ txtServerName = new JTextField(10);
|
|
|
+ txtServerName.setBackground(Color.WHITE);
|
|
|
+ txtServerName.setForeground(Color.decode("#606060"));
|
|
|
+ txtServerName.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ txtServerName.setEditable(false);
|
|
|
+ // 第九行
|
|
|
+ lblProtocol = new JLabel("访问协议:");
|
|
|
+ lblProtocol.setForeground(Color.decode("#606060"));
|
|
|
+ lblProtocol.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ // 第十行
|
|
|
+ txtProtocol = new JTextField("HTTP", 10);
|
|
|
+ txtProtocol.setBackground(Color.WHITE);
|
|
|
+ txtProtocol.setForeground(Color.decode("#606060"));
|
|
|
+ txtProtocol.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ txtProtocol.setEditable(false);
|
|
|
+ // 第十一行
|
|
|
+ lblIP = new JLabel("服务器IP:");
|
|
|
+ lblIP.setForeground(Color.decode("#606060"));
|
|
|
+ lblIP.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ // 第十二行
|
|
|
+ txtIP = new JTextField(10);
|
|
|
+ txtIP.setBackground(Color.WHITE);
|
|
|
+ txtIP.setForeground(Color.decode("#606060"));
|
|
|
+ txtIP.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ txtIP.setEditable(false);
|
|
|
+ // 第十三行
|
|
|
+ lblPort = new JLabel("服务器端口:");
|
|
|
+ lblPort.setForeground(Color.decode("#606060"));
|
|
|
+ lblPort.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ // 第十四行
|
|
|
+ txtPort = new JTextField("8000", 10);
|
|
|
+ txtPort.setBackground(Color.WHITE);
|
|
|
+ txtPort.setForeground(Color.decode("#606060"));
|
|
|
+ txtPort.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ txtPort.setEditable(false);
|
|
|
+ // 按钮
|
|
|
+ btnStop = new JButton("关闭服务器");
|
|
|
+ btnStop.addActionListener(new ActionListener() {
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ closeServer();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ btnStop.setBackground(Color.decode("#F5F5F5"));
|
|
|
+ btnStop.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ btnStop.setForeground(Color.decode("606060"));
|
|
|
+ // 日志
|
|
|
+ lblLog = new JLabel("服务器日志");
|
|
|
+ lblLog.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ lblLog.setForeground(Color.decode("#606060"));
|
|
|
+ taLog = new TextArea(20, 50);
|
|
|
+ taLog.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+
|
|
|
+ btnSaveLog = new JButton("保存日志");
|
|
|
+ btnSaveLog.addActionListener(new ActionListener() {
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ saveLog();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ btnSaveLog.setBackground(Color.decode("#F5F5F5"));
|
|
|
+ btnSaveLog.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ btnSaveLog.setForeground(Color.decode("606060"));
|
|
|
+
|
|
|
+ pnlServerInfo.add(lblStatus);
|
|
|
+ pnlServerInfo.add(txtStatus);
|
|
|
+ pnlServerInfo.add(lblNumber);
|
|
|
+ pnlServerInfo.add(txtNumber);
|
|
|
+ pnlServerInfo.add(lblMax);
|
|
|
+ pnlServerInfo.add(txtMax);
|
|
|
+ pnlServerInfo.add(lblServerName);
|
|
|
+ pnlServerInfo.add(txtServerName);
|
|
|
+ pnlServerInfo.add(lblProtocol);
|
|
|
+ pnlServerInfo.add(txtProtocol);
|
|
|
+ pnlServerInfo.add(lblIP);
|
|
|
+ pnlServerInfo.add(txtIP);
|
|
|
+ pnlServerInfo.add(lblPort);
|
|
|
+ pnlServerInfo.add(txtPort);
|
|
|
+
|
|
|
+ pnlServerInfo.setBounds(5, 5, 100, 400);
|
|
|
+ lblLog.setBounds(110, 5, 100, 30);
|
|
|
+ taLog.setBounds(110, 35, 400, 370);
|
|
|
+ btnStop.setBounds(150, 410, 120, 30);
|
|
|
+ btnSaveLog.setBounds(270, 410, 120, 30);
|
|
|
+ pnlServer.add(pnlServerInfo);
|
|
|
+ pnlServer.add(lblLog);
|
|
|
+ pnlServer.add(taLog);
|
|
|
+ pnlServer.add(btnStop);
|
|
|
+ pnlServer.add(btnSaveLog);
|
|
|
+ // 用户面板
|
|
|
+ pnlUser = new JPanel();
|
|
|
+ pnlUser.setLayout(null);
|
|
|
+ pnlUser.setBackground(new Color(245, 245, 245));
|
|
|
+ pnlUser.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+
|
|
|
+ lblMessage = new JLabel("用户消息");
|
|
|
+ lblMessage.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ lblMessage.setForeground(Color.decode("#606060"));
|
|
|
+ taMessage = new TextArea(20, 20);
|
|
|
+ taMessage.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+
|
|
|
+ lblNotice = new JLabel("通知:");
|
|
|
+ lblNotice.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ lblNotice.setForeground(Color.decode("#606060"));
|
|
|
+ txtNotice = new JTextField(20);
|
|
|
+ txtNotice.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+
|
|
|
+ btnSend = new JButton("发送");
|
|
|
+ btnSend.setBackground(Color.decode("#f5f5f5"));
|
|
|
+ btnSend.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ btnSend.setForeground(Color.decode("#606060"));
|
|
|
+ btnSend.setEnabled(true);
|
|
|
+ btnSend.addActionListener(new ActionListener() {
|
|
|
+ public void actionPerformed(ActionEvent arg0) {
|
|
|
+ serverMessage();
|
|
|
}
|
|
|
+ });
|
|
|
+
|
|
|
+ lblUserCount = new JLabel("在线总人数 0 人");
|
|
|
+ lblUserCount.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ lblUserCount.setForeground(Color.decode("#606060"));
|
|
|
+
|
|
|
+ lblUser = new JLabel("在线用户列表");
|
|
|
+ lblUser.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ lblUser.setForeground(Color.decode("#606060"));
|
|
|
+
|
|
|
+ lstUser = new JList();
|
|
|
+ lstUser.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ lstUser.setVisibleRowCount(17);
|
|
|
+ lstUser.setFixedCellWidth(180);
|
|
|
+ lstUser.setFixedCellHeight(18);
|
|
|
+
|
|
|
+ spUser = new JScrollPane();
|
|
|
+ spUser.setBackground(Color.decode("#f5f5f5"));
|
|
|
+ spUser.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ spUser.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
|
+ spUser.getViewport().setView(lstUser);
|
|
|
+
|
|
|
+ lblMessage.setBounds(5, 5, 100, 25);
|
|
|
+ taMessage.setBounds(5, 35, 300, 360);
|
|
|
+ lblUser.setBounds(310, 5, 100, 25);
|
|
|
+ spUser.setBounds(310, 35, 220, 360);
|
|
|
+ lblNotice.setBounds(5, 410, 40, 25);
|
|
|
+ txtNotice.setBounds(50, 410, 160, 25);
|
|
|
+ btnSend.setBounds(210, 410, 80, 25);
|
|
|
+ lblUserCount.setBounds(320, 410, 100, 25);
|
|
|
+
|
|
|
+ pnlUser.add(lblMessage);
|
|
|
+ pnlUser.add(taMessage);
|
|
|
+ pnlUser.add(lblUser);
|
|
|
+ pnlUser.add(spUser);
|
|
|
+
|
|
|
+ list = new JList<>();
|
|
|
+ list.setListData(new String[] { "" });
|
|
|
+ spUser.setViewportView(list);
|
|
|
+ pnlUser.add(lblNotice);
|
|
|
+ pnlUser.add(txtNotice);
|
|
|
+ pnlUser.add(btnSend);
|
|
|
+ pnlUser.add(lblUserCount);
|
|
|
+ // 主标签面板
|
|
|
+ tpServer = new JTabbedPane(JTabbedPane.LEFT);
|
|
|
+ tpServer.setBackground(Color.decode("#f5f5f5"));
|
|
|
+ tpServer.setFont(new Font("Microsoft YaHei", 0, 12));
|
|
|
+ tpServer.add("服务器管理", pnlServer);
|
|
|
+ tpServer.add("用户信息管理", pnlUser);
|
|
|
+ this.getContentPane().add(tpServer);
|
|
|
+ setVisible(true);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
protected void serverMessage() {
|
|
|
this.serverMessage = txtNotice.getText();
|
|
@@ -291,8 +287,7 @@ public class ServerFrame extends JFrame implements ActionListener {
|
|
|
|
|
|
protected void saveLog() {
|
|
|
try {
|
|
|
- FileOutputStream fileoutput = new FileOutputStream("log.txt",
|
|
|
- true);
|
|
|
+ FileOutputStream fileoutput = new FileOutputStream("log.txt", true);
|
|
|
String temp = taMessage.getText();
|
|
|
fileoutput.write(temp.getBytes());
|
|
|
fileoutput.close();
|
|
@@ -304,7 +299,7 @@ public class ServerFrame extends JFrame implements ActionListener {
|
|
|
|
|
|
private void log(String string) {
|
|
|
String newta = taMessage.getText();
|
|
|
- newta += ("\n"+string);
|
|
|
+ newta += ("\n" + string);
|
|
|
taMessage.setText(newta);
|
|
|
}
|
|
|
|