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

📄 servergui.java

📁 jsp网络考试系统,网上学生考试系统(cs版) 这是毕业设计程序,当时做的时候付出了很大的努力, 也学到很多的东西,算是对所学JAVA知识的一个综合应用吧, 做的过程中在网上找到了很多有用的东西
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * 创建日期 2006-5-15
 * 作者: 褚廷军
 * 项目名称:学生考试系统;
 * 项目要求:毕业设计;
 * 模块名称:服务器端操作界面
 * 模块功能:考试系统服务器端操作界面,管理员登录,设置考试时间,设置考试人数,
 *           查询数据库信息,维护数据库中用户信息,维护数据库中试题信息,
 *           启动服务器,监控考试信息,将学生考试信息初始化,为下一次考试做准备,
 *         (未完成功能 结束本次考试)
 *
 * 更改所生成文件模板为
 * 窗口 > 首选项 > Java > 代码生成 > 代码和注释
 */
package tserver;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.Timer;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

import tools.EditExam;
import tools.ConnectBean;
import tools.DBshow;
import tools.UserShow;

public class ServerGui extends JFrame implements ActionListener {

	private JTextArea tarea;

	private static String user;

	private static String pass;

	private Container con;

	private JMenuBar jmb;

	private JMenu fmenu;

	private JMenu hmenu;

	private JMenuItem version;

	private JToolBar toolBar;

	private JLabel stateLabel;

	private JTextField stateField;

	private JMenuItem log;

	private JMenuItem exit;

	private Box bottomBox;

	private JLabel dispTime;

	private JLabel bottom;

	private JButton setCount;

	private JButton viewuser;

	private JButton viewdb;

	private JLabel serLabel;

	private JTextArea serArea;

	private JLabel userLabel;

	private JTextArea userArea;

	private JLabel linkLabel;

	private JTextArea linkArea;

	private JToolBar toolBar1;

	private JSplitPane split_one;

	private Box leftBox, mainBox;

	private JButton serButton;

	private JButton userButton;

	private JButton linkButton;

	private JButton startSer;

	private JDialog showText;

	// private Object mainPane;
	private JScrollPane jsp,uinfoshow,sinfoshow,linfoshow;

	private JButton setTime;

	private JDialog searchStu;

	private static int timeCount = 0;

	private static String userCount = "";

	private boolean settime = false, setcount = false, start = false;

	private JButton serStop;

	private JButton inittest;

	private JButton updatexam;

	boolean tf = false;

	public ServerGui() {
		super("学生考试系统(服务器版)");
		JFrame.setDefaultLookAndFeelDecorated(true);
		// setLayout(false);
		Toolkit tool=getToolkit();
        Image ima=tool.getImage("tubiao.jpg");
        setIconImage(ima); 
		con = getContentPane();

		setMenubar();
		setJMenuBar(jmb);
		settoolBar();

		setMainBox();

		setBottomBox();
		con.add(toolBar, BorderLayout.NORTH);
		con.add(toolBar1, BorderLayout.NORTH);
		con.add(split_one, BorderLayout.CENTER);
		con.add(bottomBox, BorderLayout.SOUTH);
		setSize(800, 600);
		this.setLocation(100, 100);
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				dispose();
				System.exit(0);
			}
		});
		this.setVisible(true);

	}

	public void setMenubar() {
		jmb = new JMenuBar();
		fmenu = new JMenu("管理");
		fmenu.setToolTipText("login or exit^-^");

		log = new JMenuItem("登录");
		log.addActionListener(this);

		exit = new JMenuItem("退出");
		exit.addActionListener(this);

		fmenu.add(log);
		fmenu.add(exit);

		hmenu = new JMenu("帮助");
		hmenu.setToolTipText("show the version^-^");
		version = new JMenuItem("版本");
		version.addActionListener(this);
		hmenu.add(version);

		jmb.add(fmenu);

		jmb.add(hmenu);
	}

	public void settoolBar() {

		toolBar = new JToolBar("toolbar");
		Box stateBox = Box.createHorizontalBox();

		stateLabel = new JLabel("状 态:");
		stateField = new JTextField("欢迎你进入考试系统,请先登陆,然后选择服务", 10);
		stateField.setEditable(false);
		stateBox.add(stateLabel);
		stateBox.add(stateField);

		toolBar.add(stateBox);

		toolBar.add(Box.createHorizontalStrut(10));
		toolBar.add(Box.createHorizontalGlue());

		toolBar1 = new JToolBar("toolbar1");
		setCount = new JButton("设置人数");
		setCount.setToolTipText("set the student's number ^-^");
		setCount.setEnabled(true);
		setCount.addActionListener(this);
		setTime = new JButton("设置考试时间");
		setTime.setToolTipText("set the exam's time ^-^");
		setTime.setEnabled(true);
		setTime.addActionListener(this);

		viewdb = new JButton("数据库信息维护");
		viewdb.setToolTipText("show the DB infomation");
		setCount.setEnabled(true);
		viewdb.addActionListener(this);

		viewuser = new JButton("编辑用户信息");
		viewuser.setToolTipText("update the  student's infomation of DB");
		viewuser.setEnabled(true);
		viewuser.addActionListener(this);

		updatexam = new JButton("编辑信息试题");
		updatexam.setToolTipText("update the exam of DB");
		updatexam.setEnabled(true);
		updatexam.addActionListener(this);

		inittest = new JButton("考试信息初始化");
		inittest.setToolTipText("init the infomation of the exam");
		inittest.setEnabled(true);
		inittest.addActionListener(this);

		toolBar1.add(setCount);
		toolBar1.add(setTime);
		toolBar1.add(Box.createHorizontalStrut(20));
		toolBar1.add(viewdb);
		toolBar1.add(viewuser);
		toolBar1.add(updatexam);
		toolBar1.add(inittest);
		toolBar1.setVisible(false);
	}

	public void setBottomBox() {

		bottomBox = Box.createHorizontalBox();
		dispTime = new JLabel();
		dispTime.setHorizontalAlignment(JLabel.LEFT);
		dispTime.setForeground(Color.BLACK);

		bottom = new JLabel();
		bottom.setHorizontalAlignment(JLabel.RIGHT);
		bottom.setText("ctj_2制作   济南大学   计算0207    2002091048    &^-^&   ");

		bottomBox.add(bottom);
		bottomBox.add(dispTime);
		ActionListener time = new ActionListener() {

			public void actionPerformed(ActionEvent e) {
				dispTime.setText(new java.util.Date().toString());
			}
		};
		new Timer(1000, time).start();

	}

	public void setMainBox() {

		Font font = new Font("宋体", Font.LAYOUT_RIGHT_TO_LEFT, 14);

		leftBox = Box.createVerticalBox();
		leftBox.setForeground(Color.RED);

		leftBox.add(Box.createVerticalStrut(100));

		startSer = new JButton("启动服务器");
		startSer.setVisible(true);
		startSer.setToolTipText("start the test server ^-^");

⌨️ 快捷键说明

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