一、系统介绍
本系统实现的以下功能
管理员功能:登录系统、题目的增删改查、用户的增删改查、试题的分数设置。
考生功能:登录系统、考生考试、查看成绩、修改密码。
JDK版本:1.8
数据库:Mysql8.0.13
二、系统展示
1.登录页
2.主页面-管理员
3.添加单选题-管理员
4.添加多选题-管理员
5.添加判断题-管理员
6.修改/删除考题-管理员
7.修改试题-管理员
8.添加考题-管理员
9.添加用户-管理员
10.管理用户-管理员
11.修改用户-管理员
12.试卷参数设置-管理员
13.主页面-考生
14.开始考试-考生
15.提交试卷得分-考生
16查看成绩.-考生
17.修改密码-考生
18.关于系统-考生
三、系统实现
LoginFrame.java
package com.sjsq.view; import java.awt.Insets; import javax.swing.*; import javax.swing.GroupLayout; import javax.swing.LayoutStyle; import com.sjsq.bean.*; import com.sjsq.controller.AdminMainFrame; import com.sjsq.dao.*; /** * * @author Administrator * * @author shuijianshiqing * * @date 2021-01-17 * */ public class LoginFrame extends javax.swing.JFrame { /** Creates new form MyLand2 */ public LoginFrame() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jTextField3 = new javax.swing.JTextField(); jTextField1 = new javax.swing.JTextField(); jpanel = new MyJPanel(); choicejLabel = new javax.swing.JLabel(); userChoicejComboBox = new javax.swing.JComboBox(); choicejLabel1 = new javax.swing.JLabel(); UserNameTextField = new javax.swing.JTextField(); choicejLabel2 = new javax.swing.JLabel(); PassWordjTextField = new javax.swing.JPasswordField(); enterButton = new javax.swing.JButton(); enterButton.setMargin(new Insets(2, 2, 2, 2)); resButtonjButton = new javax.swing.JButton(); resButtonjButton.setMargin(new Insets(2, 2, 2, 2)); jTextField3.setText("jTextField3"); jTextField1.setText("jTextField1"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); choicejLabel.setText("选择用户:"); userChoicejComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "考生", "管理员" })); setTitle("考试系统"); choicejLabel1.setText("用 户 名:"); UserNameTextField.setText(""); choicejLabel2.setText(" 密 码 :"); PassWordjTextField.setText(""); enterButton.setText("登录"); enterButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { enterButtonActionPerformed(evt); } }); resButtonjButton.setText("重置"); resButtonjButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jpanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jpanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); javax.swing.GroupLayout jpanelLayout = new javax.swing.GroupLayout(jpanel); jpanelLayout.setHorizontalGroup(jpanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addGroup(jpanelLayout.createSequentialGroup().addGap(216, 216, 216).addGroup(jpanelLayout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jpanelLayout.createSequentialGroup() .addComponent(choicejLabel, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(userChoicejComboBox, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)) .addGroup(jpanelLayout.createSequentialGroup() .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jpanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jpanelLayout.createSequentialGroup() .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(choicejLabel2, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(PassWordjTextField, GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)) .addGroup(jpanelLayout.createSequentialGroup() .addComponent(choicejLabel1, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(UserNameTextField, GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))))) .addGap(82, 82, 82)) .addGroup(jpanelLayout.createSequentialGroup().addContainerGap(256, Short.MAX_VALUE) .addComponent(enterButton, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(resButtonjButton) .addGap(123, 123, 123))); jpanelLayout.setVerticalGroup(jpanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jpanelLayout.createSequentialGroup().addGap(85, 85, 85) .addGroup(jpanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(choicejLabel).addComponent(userChoicejComboBox, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jpanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(choicejLabel1).addComponent(UserNameTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jpanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(choicejLabel2).addComponent(PassWordjTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jpanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(resButtonjButton, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE) .addComponent(enterButton, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)) .addContainerGap(71, Short.MAX_VALUE))); jpanel.setLayout(jpanelLayout); pack(); } private void enterButtonActionPerformed(java.awt.event.ActionEvent evt) { if (userChoicejComboBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog(this, "没有确定路径的'用户类型'", "信息对话框", JOptionPane.WARNING_MESSAGE); return; } if (UserNameTextField.getText().equals("")) { JOptionPane.showMessageDialog(this, "用户名不能为空", "密码不能为空", JOptionPane.WARNING_MESSAGE); return; } if (PassWordjTextField.getText().equals("")) { JOptionPane.showMessageDialog(this, "密码不能为空", "信息对话框", JOptionPane.WARNING_MESSAGE); return; } MyFindUserDao findUser = new MyFindUserDao(); User user = new User(); user.setUserName(UserNameTextField.getText()); user.setPassWord(PassWordjTextField.getText()); User users = findUser.getUser(user); if ((users.getUserType() == 1 && !(userChoicejComboBox.getSelectedItem().equals("管理员")))) { JOptionPane.showMessageDialog(this, "登录系统身份不符", "信息对话框", JOptionPane.WARNING_MESSAGE); return; } if ((users.getUserType() == 0) && !(userChoicejComboBox.getSelectedItem().equals("考生"))) { JOptionPane.showMessageDialog(this, "登录系统身份不符", "信息对话框", JOptionPane.WARNING_MESSAGE); return; } // 考生 if ((users.getId() != 0) && (users.getUserType() == 0)) { int id = users.getId(); java.io.File file = new java.io.File("save.txt"); try { if (file.exists()) { file.delete(); } file.createNewFile(); java.io.FileOutputStream out = new java.io.FileOutputStream(file); byte buy[] = ("" + id).getBytes(); out.write(buy); out.close(); } catch (Exception e) { e.printStackTrace(); } InsertUserDao insertUserDao = new InsertUserDao(); insertUserDao.setUserHaveIn(users); StudentMainFrame studentExam = new StudentMainFrame(); studentExam.setVisible(true); studentExam.setBounds(200, 200, 500, 400); studentExam.setTitle("考试系统"); studentExam.setLocationRelativeTo(null); this.dispose(); } // 管理员 if ((users.getId() != 0) && (users.getUserType() == 1)) { dispose(); AdminMainFrame controller = new AdminMainFrame(); controller.setVisible(true); controller.setBounds(100, 100, 700, 500); controller.setLocationRelativeTo(null); } else if (users.getId() == 0) { JOptionPane.showMessageDialog(this, "用户名或密码错误", "信息对话框", JOptionPane.WARNING_MESSAGE); } } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { UserNameTextField.setText(""); PassWordjTextField.setText(""); } // 主函数运行 public static void main(String[] args) { LoginFrame myLand = new LoginFrame(); //myLand.setBounds(0, 0, 400, 300); myLand.setVisible(true); myLand.setLocationRelativeTo(null); } private javax.swing.JLabel choicejLabel; private javax.swing.JLabel choicejLabel1; private javax.swing.JLabel choicejLabel2; private javax.swing.JButton enterButton; private javax.swing.JButton resButtonjButton; private javax.swing.JComboBox userChoicejComboBox; private javax.swing.JPasswordField PassWordjTextField; private javax.swing.JTextField jTextField1; private javax.swing.JTextField UserNameTextField; private javax.swing.JTextField jTextField3; private MyJPanel jpanel; }
AdminMainFrame.java
/* * ControllerFrame.java * * Created on 2008年8月7日, 下午2:41 */ package com.sjsq.controller; import java.io.File; import java.security.UnresolvedPermission; import java.util.ArrayList; import javax.swing.GroupLayout; import javax.swing.JOptionPane; import javax.swing.LayoutStyle; import javax.swing.table.DefaultTableModel; import com.sjsq.bean.*; import com.sjsq.dao.FindGrade; /** * * @author Administrator */ public class AdminMainFrame extends javax.swing.JFrame {// 主控制窗体 /** Creates new form ControllerFrame */ public AdminMainFrame() {// 构造方法 initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" // desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {// 初始化方法 jPanel1 = new javax.swing.JPanel(); messageLabel = new javax.swing.JLabel(); messageJchock = new javax.swing.JComboBox(); ifLabel = new javax.swing.JLabel(); nameTextField = new javax.swing.JTextField(); findButton = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); addquestion = new javax.swing.JButton(); addUserButton = new javax.swing.JButton(); closeButton = new javax.swing.JButton(); jSeparator1 = new javax.swing.JSeparator(); downmessage = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); superControll = new javax.swing.JMenu(); addMenu = new javax.swing.JMenu(); addradioItem = new javax.swing.JMenuItem(); addmoreItem = new javax.swing.JMenuItem(); addjubje = new javax.swing.JMenuItem(); updateMenu = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); userManager = new javax.swing.JMenuItem(); findGrade = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); messageLabel.setText("查询条件:"); messageJchock.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "考生号", "考生姓名" })); ifLabel.setText("查询值:"); nameTextField.setText(""); findButton.setText("查询"); findButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { findButtonActionPerformed(evt); } }); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object[][] {}, new String[] { "考生编号", "考生姓名", "单选题得分", "多选题得分", "判断题得分", "总分", "考试时间" } )); DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); FindGrade findGradebean = new FindGrade(); java.util.List list = findGradebean.findGrade();// 把获取的所有学分用户放入list setTitle("考试系统---管理员"); if (!list.isEmpty()) { for (int j = 0; j < list.size(); j++) { Grade grade = (Grade) list.get(j); model.addRow(new Object[] { // 添加所有学分用户 grade.getId(), ChDeal.toChinese(grade.getUserName()), grade.getRadioResult(), grade.getFullResule(), grade.getEsitResult(), grade.getBatsisResult(), ChDeal.toChinese(grade.getDate()) }); } } jScrollPane1.setViewportView(jTable1); addquestion.setText("添加试题"); addquestion.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addquestionActionPerformed(evt); } }); addUserButton.setText("添加用户"); addUserButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addUserButtonActionPerformed(evt); } }); closeButton.setText("退出"); closeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { closeButtonActionPerformed(evt); } }); //downmessage.setText("版权所有:吉林省明日科技有限公司。"); //jLabel1.setText(" 网 址 :www.mrbccd.com"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jSeparator1, GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(addUserButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(addquestion, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(closeButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(12, 12, 12) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE) .addGroup( jPanel1Layout.createSequentialGroup().addComponent(messageLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(messageJchock, GroupLayout.PREFERRED_SIZE, 92, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(ifLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(nameTextField, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(findButton, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE) .addGap(31, 31, 31))))) .addContainerGap()) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(10, 10, 10).addComponent( jLabel1, GroupLayout.PREFERRED_SIZE, 195, GroupLayout.PREFERRED_SIZE)) .addComponent(downmessage, GroupLayout.PREFERRED_SIZE, 287, GroupLayout.PREFERRED_SIZE)) .addGap(135, 135, 135))))); jPanel1Layout .setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(ifLabel) .addComponent(messageJchock, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(messageLabel) .addComponent(nameTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(findButton)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(33, 33, 33) .addComponent(addquestion).addGap(43, 43, 43) .addComponent(addUserButton).addGap(42, 42, 42) .addComponent(closeButton)) .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 264, GroupLayout.PREFERRED_SIZE)) .addGap(8, 8, 8) .addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(downmessage) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel1) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel1.setLayout(jPanel1Layout); superControll.setText("题库管理"); addMenu.setText("增加考题"); addMenu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addMenuActionPerformed(evt); } }); addradioItem.setText("增加单选题"); addMenu.add(addradioItem); addradioItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addradioItemActionPerformed(evt); } }); addmoreItem.setText("增加多选题"); addmoreItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addmoreItemActionPerformed(evt); } }); addMenu.add(addmoreItem); addjubje.setText("增加判断题"); addjubje.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addjubjeActionPerformed(evt); } }); addMenu.add(addjubje); superControll.add(addMenu); updateMenu.setText("修改/删除考题"); updateMenu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { updateMenuActionPerformed(evt); } }); superControll.add(updateMenu); jMenuBar1.add(superControll); jMenu2.setText("系统管理"); userManager.setText("用户管理"); userManager.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { userManagerActionPerformed(evt); } }); jMenu2.add(userManager); findGrade.setText("参数设置"); findGrade.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { findGradeActionPerformed(evt); } }); jMenu2.add(findGrade); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jPanel1, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 620, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)); getContentPane().setLayout(layout); pack(); } private void findButtonActionPerformed(java.awt.event.ActionEvent evt) { boolean flag = false;// 没查询到为true;否则为false // 首先判断用户是否输入查询值 if (nameTextField.getText().equals("")) { JOptionPane.showMessageDialog(this, "请输入查询条件", "消息对话框", JOptionPane.WARNING_MESSAGE); return; // 如果有没有输入查询值 返回 } // 如果用户选择按“考生号”查询考分,系统将调用getGradeID()方法,并将查询结果显示在窗体中 if (messageJchock.getSelectedItem().toString().equals("考生号")) { FindGrade findGrade = new FindGrade(); java.util.List<Grade> gradeList = findGrade.findGrade(); if (!gradeList.isEmpty()) { for (int i = 0; i < gradeList.size(); i++) { Grade grade = gradeList.get(i); try { if (grade.getId() != Integer.parseInt(nameTextField.getText())) { } } catch (Exception e) { JOptionPane.showMessageDialog(this, "必须输入数字!", "信息对话框", JOptionPane.WARNING_MESSAGE); return; } if (grade.getId() == Integer.parseInt(nameTextField.getText())) { Grade gradeId = findGrade.getGradeID(grade); if (gradeId != null) { ((DefaultTableModel) jTable1.getModel()).setRowCount(0); ((DefaultTableModel) jTable1.getModel()) .addRow(new Object[] { grade.getId(), ChDeal.toChinese(grade.getUserName()), grade.getRadioResult(), grade.getFullResule(), grade.getEsitResult(), grade.getBatsisResult(), ChDeal.toChinese(grade.getDate()) }); flag = false; return; } } else { flag = true; } } if (flag) { JOptionPane.showMessageDialog(this, "没有要查询的考生成绩!", "信息对话框", JOptionPane.WARNING_MESSAGE); } } } if (messageJchock.getSelectedItem().toString().equals("考生姓名")) { FindGrade findGrade = new FindGrade(); Grade grade = new Grade(); grade.setUserName(nameTextField.getText()); Grade grage = findGrade.getGradeName(grade); if ((grade.getUserName().equals(nameTextField.getText())) && (grage.getId() != 0)) { ((DefaultTableModel) jTable1.getModel()).setRowCount(0); ((DefaultTableModel) jTable1.getModel()).addRow(new Object[] { grage.getId(), grage.getUserName(), grage.getRadioResult(), grage.getFullResule(), grage.getEsitResult(), grage.getBatsisResult(), ChDeal.toChinese(grage.getDate()) }); } else { JOptionPane.showMessageDialog(this, "没有要查询的考生成绩!", "信息对话框", JOptionPane.WARNING_MESSAGE); } } } private void addquestionActionPerformed(java.awt.event.ActionEvent evt) { AddExamFrame testFrame = new AddExamFrame(); testFrame.setVisible(true); testFrame.setBounds(200, 150, 500, 500); testFrame.setTitle("添加考题"); this.setVisible(false); testFrame.setLocationRelativeTo(null); } private void updateMenuActionPerformed(java.awt.event.ActionEvent evt) { dispose(); UpdateFrame updateFrame = new UpdateFrame(); updateFrame.setVisible(true); updateFrame.setBounds(100, 150, 630, 350); updateFrame.setLocationRelativeTo(null); } private void addUserButtonActionPerformed(java.awt.event.ActionEvent evt) { dispose(); UserAddFrame addUser = new UserAddFrame(); addUser.setVisible(true); addUser.setBounds(200, 200, 400, 300); addUser.setTitle("添加用户对话框"); addUser.setLocationRelativeTo(null); } private void findGradeActionPerformed(java.awt.event.ActionEvent evt) { dispose(); UpdateExamParameter updateExam = new UpdateExamParameter(); updateExam.setTitle("参数设置"); updateExam.setVisible(true); updateExam.setBounds(200, 150, 500, 330); updateExam.setLocationRelativeTo(null); } private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) { int n = JOptionPane.showConfirmDialog(this, "确定要退出系统吗?", "确定对话框", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { System.exit(0); } if (n == JOptionPane.NO_OPTION) { } } private void addMenuActionPerformed(java.awt.event.ActionEvent evt) { } private void addradioItemActionPerformed(java.awt.event.ActionEvent evt) { dispose(); AddRadioFrame addRadioFrame = new AddRadioFrame(); addRadioFrame.setTitle("添加单选题"); addRadioFrame.setVisible(true); addRadioFrame.setBounds(200, 100, 400, 500); addRadioFrame.setLocationRelativeTo(null); } private void addmoreItemActionPerformed(java.awt.event.ActionEvent evt) { dispose(); AddMoreFrame addMoreFrame = new AddMoreFrame(); addMoreFrame.setTitle("添加多选题"); addMoreFrame.setVisible(true); addMoreFrame.setBounds(200, 100, 400, 500); addMoreFrame.setLocationRelativeTo(null); } private void addjubjeActionPerformed(java.awt.event.ActionEvent evt) { dispose(); AddJudgeFrame addjudge = new AddJudgeFrame(); addjudge.setTitle("添加判断题"); addjudge.setVisible(true); addjudge.setBounds(200, 150, 400, 350); addjudge.setLocationRelativeTo(null); } private void userManagerActionPerformed(java.awt.event.ActionEvent evt) { dispose(); UserManagerFrame userAdd = new UserManagerFrame(); userAdd.setTitle("用户管理"); userAdd.setVisible(true); userAdd.setBounds(200, 200, 425, 330); userAdd.setLocationRelativeTo(null); } private javax.swing.JMenu addMenu; private javax.swing.JButton addUserButton; private javax.swing.JMenuItem addjubje; private javax.swing.JMenuItem addmoreItem; private javax.swing.JButton addquestion; private javax.swing.JMenuItem addradioItem; private javax.swing.JButton closeButton; private javax.swing.JLabel downmessage; private javax.swing.JButton findButton; private javax.swing.JMenuItem findGrade; private javax.swing.JLabel ifLabel; private javax.swing.JLabel jLabel1; private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; private javax.swing.JTable jTable1; private javax.swing.JTextField nameTextField; private javax.swing.JComboBox messageJchock; private javax.swing.JLabel messageLabel; private javax.swing.JMenu superControll; private javax.swing.JMenuItem updateMenu; private javax.swing.JMenuItem userManager; }
StudentMainFrame.java
/* * StudentExam.java * * Created on 2008年8月2日, 上午10:04 */ package com.sjsq.view; import java.util.List; import javax.swing.JOptionPane; import com.sjsq.bean.*; import com.sjsq.dao.*; import com.sjsq.student.ExamPage; /** * * @author Administrator */ public class StudentMainFrame extends javax.swing.JFrame { /** Creates new form StudentExam */ public StudentMainFrame() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated // Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel = new MySudentExamJPanel(); jMenuBar1 = new javax.swing.JMenuBar(); FilejMenu = new javax.swing.JMenu(); openjMenuItem = new javax.swing.JMenuItem(); closeMenuItem = new javax.swing.JMenuItem(); watchjMenu = new javax.swing.JMenu(); sleanjMenuItem = new javax.swing.JMenuItem(); amendpassjMenuItem = new javax.swing.JMenuItem(); aboutjMenu = new javax.swing.JMenu(); aboutExamMenuItem = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); FilejMenu.setText("考试"); setTitle("考试系统---考生"); openjMenuItem.setText("开始考试"); openjMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { openjMenuItemActionPerformed(evt); } }); javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(jPanel); jPanel.setLayout(jPanelLayout); jPanelLayout.setHorizontalGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE)); FilejMenu.add(openjMenuItem); closeMenuItem.setText("退出"); closeMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { closeMenuItemActionPerformed(evt); } }); FilejMenu.add(closeMenuItem); jMenuBar1.add(FilejMenu); watchjMenu.setText("查看"); sleanjMenuItem.setText("查分"); sleanjMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { sleanjMenuItemActionPerformed(evt); } }); watchjMenu.add(sleanjMenuItem); amendpassjMenuItem.setText("修改密码"); amendpassjMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { amendpassjMenuItemActionPerformed(evt); } }); watchjMenu.add(amendpassjMenuItem); jMenuBar1.add(watchjMenu); aboutjMenu.setText("关于"); aboutExamMenuItem.setText("本次考试"); aboutExamMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { aboutExamMenuItemActionPerformed(evt); } }); aboutjMenu.add(aboutExamMenuItem); jMenuBar1.add(aboutjMenu); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, Short.MAX_VALUE)); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 279, Short.MAX_VALUE)); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); pack(); } private void openjMenuItemActionPerformed(java.awt.event.ActionEvent evt) { java.io.File file = new java.io.File("save.txt"); try { java.io.FileInputStream in = new java.io.FileInputStream(file); byte byt[] = new byte[1024]; int len = in.read(byt); String strid = new String(byt, 0, len); int id = Integer.parseInt(strid); MyFindUserDao findUser = new MyFindUserDao(); User user = new User(); user.setId(id); User use = findUser.getUserID(user); System.out.println("AAA" + use.getId()); if (use.getHaveIn() == 0) { ExamPage exampage = new ExamPage(); exampage.setVisible(true); exampage.setLocationRelativeTo(null); InsertUserDao insertUser = new InsertUserDao(); use.setHaveIn(1); boolean b = insertUser.setUserHaveIn(use); } else if (use.getHaveIn() == 1) { JOptionPane.showMessageDialog(this, "你已经参加完考试了!", "信息对话框", JOptionPane.WARNING_MESSAGE); } in.close(); } catch (Exception e) { e.printStackTrace(); } } private void closeMenuItemActionPerformed(java.awt.event.ActionEvent evt) { int n = JOptionPane.showConfirmDialog(this, "确定要退出考试吗?", "确认对话框", JOptionPane.WARNING_MESSAGE); if (n == JOptionPane.YES_OPTION) { System.exit(0); } } private void sleanjMenuItemActionPerformed(java.awt.event.ActionEvent evt) { java.io.File file = new java.io.File("save.txt"); try { java.io.FileInputStream in = new java.io.FileInputStream(file); byte byt[] = new byte[1024]; int len = in.read(byt); String strid = new String(byt, 0, len); int id = Integer.parseInt(strid); FindGrade findGrade = new FindGrade(); Grade grage = new Grade(); grage.setId(id); Grade gra = findGrade.getGradeID(grage); int radioMark = gra.getRadioResult(); int fullMark = gra.getFullResule(); int judgeMark = gra.getEsitResult(); int bastMark = gra.getBatsisResult(); int sum = radioMark + fullMark + judgeMark; JOptionPane.showMessageDialog(this, "单选题得分:" + radioMark + "\n" + "多选题得分:" + fullMark + "\n" + "判断题得分:" + judgeMark + "\n" + "总分:" + sum, "信息对话框", JOptionPane.WARNING_MESSAGE); in.close(); } catch (Exception e) { e.printStackTrace(); } } private void amendpassjMenuItemActionPerformed(java.awt.event.ActionEvent evt) { dispose(); ChangePassWordFrame setPassWord = new ChangePassWordFrame(); setPassWord.setVisible(true); setPassWord.setTitle("修改密码"); setPassWord.setBounds(200, 150, 400, 300); setPassWord.setLocationRelativeTo(null); } private void aboutExamMenuItemActionPerformed(java.awt.event.ActionEvent evt) { dispose(); AboutFrame myAbout = new AboutFrame(); myAbout.setVisible(true); myAbout.setTitle("关于本次考试"); myAbout.setBounds(200, 150, 450, 350); myAbout.setLocationRelativeTo(null); } private javax.swing.JMenu FilejMenu; private javax.swing.JMenuItem aboutExamMenuItem; private javax.swing.JMenu aboutjMenu; private javax.swing.JMenuItem amendpassjMenuItem; private javax.swing.JMenuItem closeMenuItem; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem openjMenuItem; private javax.swing.JMenuItem sleanjMenuItem; private javax.swing.JMenu watchjMenu; private MySudentExamJPanel jPanel; }