⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servergui.java

📁 试题库管理系统 该系统所包含的子系统有:用户管理子系统、课程管理子系统、习题管理子系统和试卷库管理子系统。而用户管理子系统下分的模块有:添加用户、删除用户和修改用户信息;课程管理子系统下分的模块有:创
💻 JAVA
字号:
package server.pool;
import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2008</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
public class ServerGUI extends JFrame {
    JButton start = new JButton();
    JButton stop = new JButton();
    ServerPool server=new ServerPool();
    public ServerGUI() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        this.getContentPane().setBackground(SystemColor.inactiveCaption);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setForeground(Color.orange);
        this.setTitle("习题管理系统服务器");
        start.setBounds(new Rectangle(98, 31, 101, 23));
        start.setActionCommand("start");
        start.setText("启动服务器");
        start.addActionListener(new ServerGUI_start_actionAdapter(this));
        stop.setBounds(new Rectangle(99, 63, 101, 23));
        stop.setActionCommand("stop");
        stop.setText("关闭服务器");
        stop.setEnabled(false);
        stop.addActionListener(new ServerGUI_stop_actionAdapter(this));
        this.getContentPane().add(start);
        this.getContentPane().add(stop);
        this.setVisible(true);
        this.setBounds(400,400,300,150);
    }

    public void stop_actionPerformed(ActionEvent e) {
        try {
            server.closeServer();
            start.setEnabled(true);
            stop.setEnabled(false);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this,"服务器关闭失败!");
        }
    }

    public void start_actionPerformed(ActionEvent e) {
        try {
            server.startServer();
            start.setEnabled(false);
            stop.setEnabled(true);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this,"服务器启动失败!");
        }
    }
    public static void main(String[] arg){
        new ServerGUI().validate();
    }
}


class ServerGUI_start_actionAdapter implements ActionListener {
    private ServerGUI adaptee;
    ServerGUI_start_actionAdapter(ServerGUI adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.start_actionPerformed(e);
    }
}


class ServerGUI_stop_actionAdapter implements ActionListener {
    private ServerGUI adaptee;
    ServerGUI_stop_actionAdapter(ServerGUI adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.stop_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -