?? web158_com_server.java
字號:
package web158.com;
/**
* @param 李建東
*
* 聯(lián)系電話:0898-62925341
*
* 聯(lián)系QQ:813751 657597 8912740
*
* 網(wǎng) 址:
* http://www.web156.com
* http://www.web158.com
*使用本源碼,請保留版權(quán)信息,謝謝
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
import java.sql.*;
class web158_frame extends JFrame implements ActionListener, Runnable
{
//加載軟件皮膚查看系統(tǒng)配置文件是否都存在
Web158_Com_Server_Config web158_server_config=new Web158_Com_Server_Config();
//軟件皮膚Panel
web158_com_server_getSkin mainSkin=new web158_com_server_getSkin();
//添加第一行按制行
//控制行
JPanel web158_com_ordermenu=new JPanel();
//字體
Font font = new Font("宋體",0,12);
//左邊Label
JLabel web158_com_left=new JLabel();
JLabel web158_space_1=new JLabel();
JLabel web158_space_2=new JLabel();
JLabel web158_space_3=new JLabel();
JLabel web158_space_4=new JLabel();
JLabel web158_space_5=new JLabel();
// 關(guān)閉窗口按鈕
JButton web158_com_exam=new JButton(" 初始試題 ");
// 關(guān)閉窗口按鈕
JButton web158_com_stu=new JButton("考生管理");
//參數(shù)配置
JButton web158_com_config=new JButton("參數(shù)配置");
//使用幫助
JButton web158_com_help=new JButton("最 小 化");
//啟動按鈕
JButton web158_com_start=new JButton(" 啟動服務(wù) ");
//關(guān)閉窗口按鈕
JButton web158_com_close=new JButton("關(guān)閉");
//關(guān)閉窗口計(jì)時器
////////////////////////////////////////////////////////////////////////////////////////////
//計(jì)時器
//服務(wù)器啟動時間
Timer timer;
int m,n;
//關(guān)閉窗口所用的時間
Timer closetimer;
int c=60;
////////////////////////////////////
//中間變動面板
JPanel web158_com_Cpanel=new JPanel();
//右邊變動面板////////////////////////////////////////////////////////////////////////////////
JPanel web158_com_Rpanel=new JPanel();
//上部PANEL
JPanel web158_r_space=new JPanel();
//已經(jīng)取試題考生
JTextPane txtinfo=new JTextPane();
//交人欄
//上部PANEL
JPanel web158_r_space2=new JPanel();
//已經(jīng)取試題考生
JTextPane txtinfo2=new JTextPane();
//交人數(shù)
int getNum=0;
int subNum=0;
/*
*
* 底部板權(quán)
*
*/
JPanel web158_bottom=new JPanel();
JButton web158_com_copy=new JButton("關(guān)于本軟件 網(wǎng)址:http://www.web158.com ");
// 中Label
JLabel web158_com_s_1=new JLabel();
//考生信息
JLabel web158_com_b_1=new JLabel();
private ServerSocket ss;
private Socket socket;
private BufferedReader in;
private PrintWriter out;
private int port=10000;
private int sendport=8852;
String line="";
Thread thread;
//需要取的試題數(shù)
int choose_num=15;
//操作題數(shù)量
int operate_num=2;
//試題不多是否提示
boolean alertnotgo=false;
//數(shù)據(jù)庫加載
Web158_Com_Server_DBConn db=new Web158_Com_Server_DBConn();
//以下為初始化考生列表名單
Web158_Com_Server_Stulist stulist=new Web158_Com_Server_Stulist();
//入口
web158_frame()
{
//關(guān)閉窗口線程初始化
closetimer=new Timer(10,this);
//開始時間
timer=new Timer(1000,this);
//線程
thread=new Thread(this);
//是否所有文件都存在
String okorerror=web158_server_config.web158com_service_config_ok();
if(okorerror.equals("allok"))
{
//空間
web158_space_1.setPreferredSize(new Dimension(13,30));
web158_space_2.setPreferredSize(new Dimension(20,30));
web158_space_3.setPreferredSize(new Dimension(30,30));
web158_space_4.setPreferredSize(new Dimension(25,30));
web158_space_5.setPreferredSize(new Dimension(25,30));
web158_com_ordermenu.add(web158_space_1);
//添加試題
web158_com_exam.setBackground(Color.white);
web158_com_exam.setFont(font);
web158_com_exam.setCursor(new Cursor(Cursor.HAND_CURSOR));
web158_com_exam.setBorder(null);
web158_com_exam.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
//web158_info();
//timer.start();
goExaminfo();
}
});//end of actionPerformed
//添加系統(tǒng)按鈕
web158_com_ordermenu.add(web158_com_exam);
web158_com_ordermenu.add(web158_space_2);
//試卷提交按鈕
web158_com_stu.setBackground(Color.white);
web158_com_stu.setFont(font);
web158_com_stu.setCursor(new Cursor(Cursor.HAND_CURSOR));
web158_com_stu.setBorder(null);
web158_com_stu.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
goStuinfo();
}
});
//添加系統(tǒng)按鈕
web158_com_ordermenu.add(web158_com_stu);
web158_com_ordermenu.add(web158_space_3);
//參數(shù)配置
web158_com_config.setBackground(Color.white);
web158_com_config.setFont(font);
web158_com_config.setCursor(new Cursor(Cursor.HAND_CURSOR));
web158_com_config.setBorder(null);
web158_com_config.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
goInfoinfo();
}
});
//添加系統(tǒng)按鈕
web158_com_ordermenu.add(web158_com_config);
web158_com_ordermenu.add(web158_space_4);
//使用幫助
web158_com_help.setBackground(Color.white);
web158_com_help.setFont(font);
web158_com_help.setCursor(new Cursor(Cursor.HAND_CURSOR));
web158_com_help.setBorder(null);
web158_com_help.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
//goHelpinfo();
}
});
//添加系統(tǒng)按鈕
web158_com_ordermenu.add(web158_com_help);
web158_com_ordermenu.add(web158_space_5);
//啟動服務(wù)
web158_com_start.setBackground(Color.white);
web158_com_start.setFont(font);
web158_com_start.setForeground(Color.red);
web158_com_start.setCursor(new Cursor(Cursor.HAND_CURSOR));
web158_com_start.setBorder(null);
web158_com_start.setActionCommand("start");
web158_com_start.addActionListener(this);//end of actionPerformed
//添加啟動服務(wù)器按鈕
web158_com_ordermenu.add(web158_com_start);
//添加空白面板
web158_com_left.setPreferredSize(new Dimension(310,35));
web158_com_left.setFont(font);
web158_com_left.setText(" 服務(wù)器已運(yùn)行: ");
web158_com_ordermenu.add(web158_com_left);//添加到主面板
//關(guān)閉按鈕
web158_com_close.setBackground(Color.white);
web158_com_close.setFont(font);
web158_com_close.setCursor(new Cursor(Cursor.HAND_CURSOR));
web158_com_close.setBorder(null);
//添加關(guān)閉按鈕
web158_com_close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
closetimer.start();
//System.exit(0);
}
});//end of actionPerformed
web158_com_ordermenu.add(web158_com_close);
//工具欄
web158_com_ordermenu.setPreferredSize(new Dimension(780,40));
web158_com_ordermenu.setOpaque(false);//透明
mainSkin.add(web158_com_ordermenu);//添加到主面板
//初始化定向到考生面板
goStuinfo();
//變動面板
web158_com_Cpanel.setPreferredSize(new Dimension(520,510));
web158_com_Cpanel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
web158_com_Cpanel.setOpaque(false);
web158_com_Cpanel.setLayout(new FlowLayout());
web158_com_Cpanel.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {}
});//end of frame.addMouseMotionListener()
//右邊主區(qū)
//添加上面空白
web158_r_space.setPreferredSize(new Dimension(215,12));
web158_r_space.setOpaque(false);
web158_com_Rpanel.add(web158_r_space);
//添加考試規(guī)則
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setPreferredSize(new Dimension(200,230));
scrollPane.setBorder(null);
scrollPane.getHorizontalScrollBar().setUI(null);
web158_com_Rpanel.add(scrollPane);
//考生手則及提示信息區(qū)
txtinfo.setBackground(new Color(207,207,157));
txtinfo.setSize(200,157);
txtinfo.setEditable(false);
txtinfo.setText("還沒有考生領(lǐng)取試卷");
scrollPane.setViewportView(txtinfo);
//右邊主區(qū)
//添加上面空白
web158_r_space2.setPreferredSize(new Dimension(215,25));
web158_r_space2.setOpaque(false);
web158_com_Rpanel.add(web158_r_space2);
//添加考試規(guī)則
final JScrollPane scrollPane2 = new JScrollPane();
scrollPane2.setPreferredSize(new Dimension(200,215));
scrollPane2.setBorder(null);
web158_com_Rpanel.add(scrollPane2);
//考生手則及提示信息區(qū)
txtinfo2.setBackground(new Color(207,207,157));
txtinfo2.setEditable(false);
txtinfo2.setText("還沒有人交卷");
scrollPane2.setViewportView(txtinfo2);
//添加右邊面板
web158_com_Rpanel.setPreferredSize(new Dimension(215,510));
web158_com_Rpanel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
web158_com_Rpanel.setOpaque(false);
web158_com_Rpanel.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {}
});//end of frame.addMouseMotionListener()
web158_com_Rpanel.setLayout(new FlowLayout(FlowLayout.LEFT));
mainSkin.add(web158_com_Cpanel);//添加到主面板
mainSkin.add(web158_com_Rpanel);//添加到主面板
//底部版權(quán)
web158_com_copy.setBackground(Color.white);
web158_com_copy.setFont(font);
web158_com_copy.setCursor(new Cursor(Cursor.HAND_CURSOR));
web158_com_copy.setBorder(null);
web158_com_copy.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
if(web158_server_config.gotoWeb158_com()==false)
{
JOptionPane.showMessageDialog(null, "您的系統(tǒng)不支持直接打開!\n\n請您直接打開網(wǎng)站:http://www.web158.com\n\n聯(lián)系QQ:813751 657597");
}
}
});//end of actionPerformed
web158_bottom.add(web158_com_copy);
//添加空格LABEL
web158_com_s_1.setPreferredSize(new Dimension(200,23));
web158_bottom.add(web158_com_s_1);
//添加考生信息
web158_com_b_1.setFont(font);
web158_com_b_1.setPreferredSize(new Dimension(250,23));
//考生信息
web158_com_b_1.setText("華夏網(wǎng)建在線考試系統(tǒng)---監(jiān)考服務(wù)器系統(tǒng)");
web158_bottom.add(web158_com_b_1);
//底部主板
web158_bottom.setLayout(new FlowLayout());
web158_bottom.setPreferredSize(new Dimension(700,30));
web158_bottom.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
web158_bottom.setOpaque(false);
mainSkin.add(web158_bottom);//添加到主面板
//主面板大小
mainSkin.setSize(800,600);
mainSkin.setCursor(new Cursor(Cursor.HAND_CURSOR));
//f_main.setHgap(10);
mainSkin.setLayout(new FlowLayout());
//添加面板
add(mainSkin);
//窗口屬性
//標(biāo)題
setTitle("華夏網(wǎng)建在線考試系統(tǒng)");
//圖標(biāo)
setIconImage(Toolkit.getDefaultToolkit().createImage("web158_com_config/info.dll"));//設(shè)置圖標(biāo)
//無邊
setUndecorated(true);
//大小
setSize(800,600);
//總在最前
//setAlwaysOnTop(true);
//可見
setVisible(true);
//如不加關(guān)閉窗口事件,只能不顯示,可是進(jìn)程沒有關(guān)閉造成系統(tǒng)資源浪費(fèi)!
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);//退出整個系統(tǒng)
}
});
//居中顯示
web158_com_goCenter();
//有效
validate();
}
//有文件丟失則退出系統(tǒng)
else
{
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -