//建立server框架 public Server() {
initComponents(); }
private void initComponents() {
jPanel1 = new JPanel(); jLabel2 = new JLabel(); jLabel3 = new JLabel(); jLabel4 = new JLabel(); jLabel5 = new JLabel();
jScrollPane1 = new JScrollPane();
jList1 = new JList(); jLabel1 = new JLabel();
menuBar = new JMenuBar();
fileMenu = new JMenu();
startMenuItem = new JMenuItem(); stopMenuItem = new JMenuItem();
commandMenu = new JMenu();
warnMenuItem = new JMenuItem(); kickMenuItem = new JMenuItem(); msgMenuItem = new JMenuItem();
helpMenu = new JMenu();
helpMenuItem = new JMenuItem(); aboutMenuItem = new JMenuItem();
getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());
setTitle(\服务器端\
setResizable(false);//用户不能手动调整列宽度。
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) { exitForm(evt); } });
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); try
第 10 页 共 69 页
10
{
//建立InetAddress对象
InetAddress intel=InetAddress.getLocalHost(); String SerName=intel.getHostName(); String SerIp=intel.getHostAddress();
jLabel2.setText(\服务器名:\显示服务器端主机名 jLabel3.setText(\服务器IP:\显示服务器端IP }
catch(UnknownHostException e2) {
System.out.println(\发生错误!\ }
jLabel2.setForeground(new Color(255,0,0)); jLabel2.setFont(new Font(\宋体\ jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1));
jLabel3.setForeground(new Color(255, 0, 0)); jLabel3.setFont(new Font(\宋体\ jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, -1, -1));
jLabel4.setText(\服务器状态:未启动\
jLabel4.setForeground(new Color(255, 255, 0)); jLabel4.setFont(new Font(\宋体\ jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 240, -1, -1));
jLabel5.setText(\共有:0个客户在线\
jLabel5.setForeground(new Color(255, 255, 51)); jLabel5.setFont(new Font(\宋体\ jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 240, -1, -1));
menu = new JPopupMenu(); //右键事件菜单
JMenuItem Admonition= new JMenuItem(\警告\
Admonition.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int state=JOptionPane.showOptionDialog(null,\确实要警告用户\吗?\确认\ if(state==JOptionPane.OK_OPTION) {
warnMenuItemActionPerformed(e); }
第 11 页 共 69 页
11
} });
JMenuItem Delete = new JMenuItem(\删除\ Delete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int state=JOptionPane.showOptionDialog(null,\确实要删除用户\吗?\确认\ if(state==JOptionPane.OK_OPTION) {
kickMenuItemActionPerformed(e); } } });
menu.add(Admonition); menu.add(Delete);
jList1.setModel(new AbstractListModel() { String[] strings = {};
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; } });
jList1.setFont(new Font(\ jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jList1.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent evt) {
if (evt.getClickCount()==1) {
BlackList=(String)jList1.getSelectedValue(); } }
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent(), evt.getX(), evt.getY()); } } });
jScrollPane1.setViewportView(jList1);
jPanel1.add(jScrollPane1, org.netbeans.lib.awtextra.AbsoluteConstraints(20, 45, 362, 190));
jLabel1.setIcon(new ImageIcon(\
第 12 页 共 69 页
12
new
jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, -10, -1, -1));
getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 400, 270));
menuBar.setBorder(null);
menuBar.setBackground(new Color(0, 0, 0));
fileMenu.setForeground(new Color(255, 255, 255)); fileMenu.setText(\文件\
fileMenu.setBackground(new Color(0, 0, 0)); fileMenu.setFont(new Font(\宋体\
startMenuItem.setForeground(new Color(255, 255, 255)); startMenuItem.setFont(new Font(\宋体\ startMenuItem.setText(\启动\
startMenuItem.setBackground(new Color(0, 0, 0)); startMenuItem.setBorder(null);
startMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { startMenuItemActionPerformed(evt); } });
fileMenu.add(startMenuItem);
stopMenuItem.setForeground(new Color(255, 255, 255)); stopMenuItem.setFont(new Font(\宋体\ stopMenuItem.setText(\结束\
stopMenuItem.setBackground(new Color(0, 0, 0)); stopMenuItem.setBorder(null);
stopMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { stopMenuItemActionPerformed(evt); } });
fileMenu.add(stopMenuItem);
menuBar.add(fileMenu);
commandMenu.setForeground(new Color(255, 255, 255)); commandMenu.setText(\命令\
commandMenu.setBackground(new Color(0, 0, 0)); commandMenu.setFont(new Font(\宋体\
msgMenuItem.setForeground(new Color(255, 255, 255)); msgMenuItem.setFont(new Font(\宋体\ msgMenuItem.setText(\公告\
msgMenuItem.setBackground(new Color(0, 0, 0)); msgMenuItem.setBorder(null);
msgMenuItem.addActionListener(new ActionListener() {
第 13 页 共 69 页
13
public void actionPerformed(ActionEvent evt) { msgMenuItemActionPerformed(evt); } });
commandMenu.add(msgMenuItem);
warnMenuItem.setForeground(new Color(255, 255, 255)); warnMenuItem.setFont(new Font(\宋体\ warnMenuItem.setText(\警告\
warnMenuItem.setBackground(new Color(0, 0, 0)); warnMenuItem.setBorder(null);
warnMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { warnMenuItemActionPerformed(evt); } });
commandMenu.add(warnMenuItem);
kickMenuItem.setForeground(new Color(255, 255, 255)); kickMenuItem.setFont(new Font(\宋体\ kickMenuItem.setText(\踢人\
kickMenuItem.setBackground(new Color(0, 0, 0)); kickMenuItem.setBorder(null);
kickMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { kickMenuItemActionPerformed(evt); } });
commandMenu.add(kickMenuItem);
menuBar.add(commandMenu);
helpMenu.setForeground(new Color(255, 255, 255)); helpMenu.setText(\帮助\
helpMenu.setBackground(new Color(0, 0, 0)); helpMenu.setFont(new Font(\宋体\
helpMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { helpMenuActionPerformed(evt); } });
helpMenuItem.setForeground(new Color(255, 255, 255)); helpMenuItem.setFont(new Font(\宋体\ helpMenuItem.setText(\帮助主题\
helpMenuItem.setBackground(new Color(0, 0, 0)); helpMenuItem.setBorder(null);
helpMenuItem.addActionListener(new ActionListener() {
第 14 页 共 69 页
14
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Java聊天室系统程序设计实验报告 - 图文(3)在线全文阅读。
相关推荐: