?? servergui.java
字號:
/*
* 創(chuàng)建日期 2006-5-15
* 作者: 褚廷軍
* 項(xiàng)目名稱:學(xué)生考試系統(tǒng);
* 項(xiàng)目要求:畢業(yè)設(shè)計(jì);
* 模塊名稱:服務(wù)器端操作界面
* 模塊功能:考試系統(tǒng)服務(wù)器端操作界面,管理員登錄,設(shè)置考試時間,設(shè)置考試人數(shù),
* 查詢數(shù)據(jù)庫信息,維護(hù)數(shù)據(jù)庫中用戶信息,維護(hù)數(shù)據(jù)庫中試題信息,
* 啟動服務(wù)器,監(jiān)控考試信息,將學(xué)生考試信息初始化,為下一次考試做準(zhǔn)備,
* (未完成功能 結(jié)束本次考試)
*
* 更改所生成文件模板為
* 窗口 > 首選項(xiàng) > 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("學(xué)生考試系統(tǒng)(服務(wù)器版)");
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("狀 態(tài):");
stateField = new JTextField("歡迎你進(jìn)入考試系統(tǒng),請先登陸,然后選擇服務(wù)", 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("設(shè)置人數(shù)");
setCount.setToolTipText("set the student's number ^-^");
setCount.setEnabled(true);
setCount.addActionListener(this);
setTime = new JButton("設(shè)置考試時間");
setTime.setToolTipText("set the exam's time ^-^");
setTime.setEnabled(true);
setTime.addActionListener(this);
viewdb = new JButton("數(shù)據(jù)庫信息維護(hù)");
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制作 濟(jì)南大學(xué) 計(jì)算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("啟動服務(wù)器");
startSer.setVisible(true);
startSer.setToolTipText("start the test server ^-^");
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -