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;
}
/*
-
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 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;
}
/*
-
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;
}
/*
-
AddJudge.java
-
Created on 2008年8月9日, 下午5:02
*/
package com.sjsq.controller;
import javax.swing.JOptionPane;
import com.sjsq.bean.*;
import com.sjsq.dao.FindQuestionDao;
/**
-
@author Administrator
*/
public class AddJudgeFrame extends javax.swing.JFrame {// 增加判断
/** Creates new form AddJudge */
public AddJudgeFrame() { // 构造方法
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() {// 初始化方法
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
addJudgejLabel = new javax.swing.JLabel();
idCountjLabel = new javax.swing.JLabel();
idjTextField = new javax.swing.JTextField();
idCountjLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
NamejTextArea = new javax.swing.JTextArea();
answerJLabel = new javax.swing.JLabel();
answerjTextField1 = new javax.swing.JTextField();
addjButton = new javax.swing.JButton();
resjButton = new javax.swing.JButton();
resjButton1 = new javax.swing.JButton();
remarkLabel = new javax.swing.JLabel();
remarkjTextField = new javax.swing.JTextField();
jLabel1.setText(“”);
setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {// 关闭窗口监听方法
formWindowClosing(evt);
}
});
setTitle(“添加判断题”);
addJudgejLabel.setText(“添加判断题模块:”);
idCountjLabel.setText(“试题编号:”);
FindQuestionDao findDao = new FindQuestionDao();
int id = findDao.findQMid();
idjTextField.setText(“” + (id + 1));
idjTextField.setEditable(false);
idCountjLabel1.setText(“试题题目:”);
NamejTextArea.setColumns(20);
NamejTextArea.setRows(5);
jScrollPane1.setViewportView(NamejTextArea);
answerJLabel.setText(“试题答案:”);
answerjTextField1.setText(“”);
addjButton.setText(“添加”);
addjButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addjButtonActionPerformed(evt);
}
});
resjButton.setText(“重置”);
resjButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
resjButtonActionPerformed(evt);
}
});
resjButton1.setText(“关闭”);
resjButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
resjButton1ActionPerformed(evt);
}
});
remarkLabel.setText(" 备 注:");
remarkjTextField.setText(“”);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup().addContainerGap(100, Short.MAX_VALUE)
.addComponent(addJudgejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 186,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(105, 105, 105))
.addGroup(jPanel1Layout.createSequentialGroup().addGap(82, 82, 82).addComponent(addjButton)
.addGap(18, 18, 18).addComponent(resjButton).addGap(18, 18, 18).addComponent(resjButton1)
.addContainerGap(102, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup().addGap(27, 27, 27).addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(remarkLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
remarkjTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup().addComponent(idCountjLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(idjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 254,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup().addComponent(idCountjLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup().addComponent(answerJLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
answerjTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE)))
.addGap(46, 46, 46)));
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(addJudgejLabel)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(idCountjLabel).addComponent(idjTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(idCountjLabel1)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(8, 8, 8)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(answerJLabel)
.addComponent(answerjTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(remarkLabel)
.addComponent(remarkjTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addjButton).addComponent(resjButton).addComponent(resjButton1))
.addContainerGap()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 280,
Short.MAX_VALUE));
pack();
}
private void addjButtonActionPerformed(java.awt.event.ActionEvent evt) {
if (NamejTextArea.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “试题题目不能为空!”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (answerjTextField1.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “试题答案不能为空!”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (!(answerjTextField1.getText().equals(“正确”)) && !(answerjTextField1.getText().equals(“错误”))) {
JOptionPane.showMessageDialog(this, “试题答案只能是‘正确’或‘错误’两种!”, “消息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
Question question = new Question();
question.setId(Integer.parseInt(idjTextField.getText()));
FindQuestionDao findQuestion = new FindQuestionDao();
QuestionType qtype = new QuestionType();
qtype.setQName(“判断题”);
QuestionType questype = findQuestion.getQuestionTypeID(qtype);
question.setTypeid(questype.getId());
question.setQ_subject(ChDeal.toISO(NamejTextArea.getText()));
question.setQ_answer(ChDeal.toISO(answerjTextField1.getText()));
question.setOptionA(“”);
question.setOptionB(“”);
question.setOptionC(“”);
question.setOptionD(“”);
System.out.println("sssssssssssssssssssss " + remarkjTextField.getText());
question.setNote(remarkjTextField.getText());
boolean bool = findQuestion.setQuestionDBbean(question);
if (bool == true) {
JOptionPane.showMessageDialog(this, “判断题添加成功!”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
dispose();
AdminMainFrame cont = new AdminMainFrame();
cont.setVisible(true);
cont.setLocationRelativeTo(null);
}
}
private void resjButtonActionPerformed(java.awt.event.ActionEvent evt) {
NamejTextArea.setText(“”);
answerjTextField1.setText(“”);
remarkjTextField.setText(“”);
}
private void resjButton1ActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
AdminMainFrame controller = new AdminMainFrame();
controller.setVisible(true);
controller.setBounds(100, 200, 650, 450);
controller.setLocationRelativeTo(null);
}
private void formWindowClosing(java.awt.event.WindowEvent evt) {
dispose();
AdminMainFrame controll = new AdminMainFrame();
controll.setVisible(true);
controll.setLocationRelativeTo(null);
}
/**
-
@param args
-
the command line arguments
*/
private javax.swing.JTextArea NamejTextArea;
private javax.swing.JLabel addJudgejLabel;
private javax.swing.JButton addjButton;
private javax.swing.JLabel answerJLabel;
private javax.swing.JTextField answerjTextField1;
private javax.swing.JLabel idCountjLabel;
private javax.swing.JLabel idCountjLabel1;
private javax.swing.JTextField idjTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel remarkLabel;
private javax.swing.JTextField remarkjTextField;
private javax.swing.JButton resjButton;
private javax.swing.JButton resjButton1;
}
/*
-
AddRadioFrame.java
-
Created on 2008年8月9日, 下午2:45
*/
package com.sjsq.controller;
import javax.swing.JOptionPane;
import com.sjsq.bean.*;
import com.sjsq.dao.FindQuestionDao;
/**
-
@author Administrator
*/
public class AddMoreFrame extends javax.swing.JFrame { // 多选题
/** Creates new form AddRadioFrame */
public AddMoreFrame() {// 构造方法
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() {// 初始化方法
jLabel2 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
messageLabel = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
idTextField = new javax.swing.JTextField();
NameJLabel = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
NamejTextArea = new javax.swing.JTextArea();
jSeparator1 = new javax.swing.JSeparator();
answerJLabel = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
optionATextField = new javax.swing.JTextField();
answerB = new javax.swing.JLabel();
optionBTextField = new javax.swing.JTextField();
answerC = new javax.swing.JLabel();
optionCTextField = new javax.swing.JTextField();
answerC1 = new javax.swing.JLabel();
optionDTextField = new javax.swing.JTextField();
jSeparator2 = new javax.swing.JSeparator();
jLabel4 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
addjButton = new javax.swing.JButton();
resButton = new javax.swing.JButton();
noteTextField = new javax.swing.JTextField();
closejButton = new javax.swing.JButton();
jLabel2.setText(“jLabel2”);
setSize(400, 600);
setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
messageLabel.setText(“增加多选题模块,要填满一下所有各项。”);
FindQuestionDao findDao = new FindQuestionDao();
java.util.List list = findDao.findQuestion();
int id = 0;// 题目编号
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Question question = (Question) list.get(i);
id = question.getId();// 获取list集合中所有的试题id
}
}
jLabel1.setText(“题目编号:”);
idTextField.setText(“” + (id + 1));
idTextField.setEditable(false);
NameJLabel.setText(“题目题目:”);
NamejTextArea.setColumns(20);
NamejTextArea.setRows(5);
jScrollPane1.setViewportView(NamejTextArea);
answerJLabel.setText(“备选答案区:”);
jLabel3.setText(“答案A:”);
answerB.setText(“答案B:”);
answerC.setText(“答案C:”);
answerC1.setText(“答案D:”);
jLabel4.setText(“答案:”);
jLabel5.setText(“备 注:”);
addjButton.setText(“添加”);
addjButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addjButtonActionPerformed(evt);
}
});
resButton.setText(“重置”);
resButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
resButtonActionPerformed(evt);
}
});
closejButton.setText(“退出”);
closejButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
closejButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup().addContainerGap(66, Short.MAX_VALUE)
.addComponent(messageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 304,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(jPanel1Layout.createSequentialGroup().addGap(98, 98, 98).addComponent(addjButton)
.addGap(18, 18, 18).addComponent(resButton).addGap(18, 18, 18).addComponent(closejButton)
.addContainerGap())
.addGroup(jPanel1Layout.createSequentialGroup().addGap(37, 37, 37).addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 308,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup().addGap(22, 22, 22).addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 230,
Short.MAX_VALUE)
.addGap(51, 51, 51))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup().addGap(18, 18, 18).addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(answerC,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(answerB,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(
answerC1, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(noteTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addComponent(optionDTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addComponent(optionCTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addComponent(optionBTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addComponent(optionATextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE))
.addGap(48, 48, 48))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(answerJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createSequentialGroup().addComponent(jLabel1)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(idTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, 231,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createSequentialGroup().addComponent(NameJLabel)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)))
.addGap(48, 48, 48))))));
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(messageLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1).addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup().addGap(10, 10, 10).addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup().addGap(35, 35, 35)
.addComponent(NameJLabel)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(answerJLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3).addComponent(optionATextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(answerB).addComponent(optionBTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(answerC).addComponent(optionCTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(answerC1).addComponent(optionDTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(noteTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addGap(13, 13, 13)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addjButton).addComponent(resButton).addComponent(closejButton))
.addContainerGap(31, Short.MAX_VALUE)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup().addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addContainerGap()));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
pack();
}
private void addjButtonActionPerformed(java.awt.event.ActionEvent evt) {
if (NamejTextArea.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “试题题目不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (optionATextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “选项A不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (optionBTextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “选项B不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (optionCTextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “选项C不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (optionDTextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “选项D不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (noteTextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “需要添加备注”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if ((jTextField1.getText().length() > 1) && (jTextField1.getText().indexOf(“,”) == -1)) {
JOptionPane.showMessageDialog(this, “多选题要求答案格式如:‘A,B,C,D’”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
FindQuestionDao findQuestion = new FindQuestionDao();
Question question = new Question();
question.setId(Integer.parseInt(idTextField.getText()));
question.setQ_subject(ChDeal.toISO(NamejTextArea.getText()));
question.setQ_answer(ChDeal.toISO(jTextField1.getText()));
question.setOptionA(ChDeal.toISO(optionATextField.getText()));
QuestionType questionType = new QuestionType();
questionType.setQName(ChDeal.toISO(“多选题”));
QuestionType qtype = findQuestion.getQuestionTypeID(questionType);
question.setTypeid(qtype.getId());
question.setOptionB(ChDeal.toISO(optionBTextField.getText()));
question.setOptionC(ChDeal.toISO(optionCTextField.getText()));
question.setOptionD(ChDeal.toISO(optionDTextField.getText()));
question.setNote(noteTextField.getText());
boolean bool = findQuestion.setQuestionDBbean(question);
if (bool == true) {
JOptionPane.showMessageDialog(this, “信息添加成功”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
dispose();
AdminMainFrame controllerFrame = new AdminMainFrame();
controllerFrame.setVisible(true);
controllerFrame.setLocationRelativeTo(null);
}
}
private void resButtonActionPerformed(java.awt.event.ActionEvent evt) {
NamejTextArea.setText(“”);
jTextField1.setText(“”);
optionATextField.setText(“”);
optionBTextField.setText(“”);
optionCTextField.setText(“”);
optionDTextField.setText(“”);
}
// 关闭窗口,返回主页面
private void closejButtonActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
AdminMainFrame controller = new AdminMainFrame();
controller.setVisible(true);
controller.setBounds(100, 200, 650, 450);
controller.setLocationRelativeTo(null);
}
private void formWindowClosing(java.awt.event.WindowEvent evt) {
dispose();
AdminMainFrame controll = new AdminMainFrame();
controll.setVisible(true);
controll.setLocationRelativeTo(null);
}
/**
-
@param args
-
the command line arguments
*/
private javax.swing.JLabel NameJLabel;
private javax.swing.JButton addjButton;
private javax.swing.JLabel answerB;
private javax.swing.JLabel answerC;
private javax.swing.JLabel answerC1;
private javax.swing.JLabel answerJLabel;
private javax.swing.JButton closejButton;
private javax.swing.JTextField idTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextArea NamejTextArea;
private javax.swing.JTextField jTextField1;
private javax.swing.JLabel messageLabel;
private javax.swing.JTextField noteTextField;
private javax.swing.JTextField optionATextField;
private javax.swing.JTextField optionBTextField;
private javax.swing.JTextField optionCTextField;
private javax.swing.JTextField optionDTextField;
private javax.swing.JButton resButton;
}
/*
-
AddRadioFrame.java
-
Created on 2008年8月9日, 下午2:45
*/
package com.sjsq.controller;
import javax.swing.JOptionPane;
import com.sjsq.bean.*;
import com.sjsq.dao.FindQuestionDao;
/**
-
@author Administrator
*/
public class AddRadioFrame extends javax.swing.JFrame {// 单选题
/** Creates new form AddRadioFrame */
public AddRadioFrame() {// 构造方法
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() {// 初始化方法
jLabel2 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
messageLabel = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
idTextField = new javax.swing.JTextField();
NameJLabel = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
NamejTextArea = new javax.swing.JTextArea();
jSeparator1 = new javax.swing.JSeparator();
answerJLabel = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
optionATextField = new javax.swing.JTextField();
answerB = new javax.swing.JLabel();
optionBTextField = new javax.swing.JTextField();
answerC = new javax.swing.JLabel();
optionCTextField = new javax.swing.JTextField();
answerC1 = new javax.swing.JLabel();
optionDTextField = new javax.swing.JTextField();
jSeparator2 = new javax.swing.JSeparator();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
note = new javax.swing.JTextField();
jTextField1 = new javax.swing.JTextField();
addjButton = new javax.swing.JButton();
resButton = new javax.swing.JButton();
closejButton = new javax.swing.JButton();
jLabel2.setText(“jLabel2”);
setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
messageLabel.setText(“增加单选题模块,要填满一下所有各项。”);
FindQuestionDao findDao = new FindQuestionDao();
int id = findDao.findQMid();// 获得最大的id号
jLabel1.setText(“题目编号:”);
idTextField.setText(“” + (id + 1));
idTextField.setEditable(false);
NameJLabel.setText(“题目题目:”);
NamejTextArea.setColumns(20);
NamejTextArea.setRows(5);
jScrollPane1.setViewportView(NamejTextArea);
answerJLabel.setText(“备选答案区:”);
jLabel3.setText(“答案A:”);
answerB.setText(“答案B:”);
answerC.setText(“答案C:”);
answerC1.setText(“答案D:”);
jLabel4.setText(“答案:”);
jLabel5.setText(“备注”);
addjButton.setText(“添加”);
addjButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addjButtonActionPerformed(evt);
}
});
resButton.setText(“重置”);
resButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
resButtonActionPerformed(evt);
}
});
closejButton.setText(“退出”);
closejButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
closejButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup().addContainerGap(66, Short.MAX_VALUE)
.addComponent(messageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 304,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(jPanel1Layout.createSequentialGroup().addGap(98, 98, 98).addComponent(addjButton)
.addGap(18, 18, 18).addComponent(resButton).addGap(18, 18, 18).addComponent(closejButton)
.addContainerGap())
.addGroup(jPanel1Layout.createSequentialGroup().addGap(37, 37, 37).addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 308,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup().addGap(22, 22, 22).addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 230,
Short.MAX_VALUE)
.addGap(51, 51, 51))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup().addGap(18, 18, 18).addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(answerC,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(answerB,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(
answerC1, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(note, javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addComponent(optionDTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addComponent(optionCTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addComponent(optionBTextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)
.addComponent(optionATextField,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE))
.addGap(48, 48, 48))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(answerJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createSequentialGroup().addComponent(jLabel1)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(idTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, 231,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createSequentialGroup().addComponent(NameJLabel)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE, 231,
Short.MAX_VALUE)))
.addGap(48, 48, 48))))));
jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(messageLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1).addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup().addGap(10, 10, 10).addComponent(
jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 71,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup().addGap(35, 35, 35)
.addComponent(NameJLabel)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(answerJLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3).addComponent(optionATextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(answerB).addComponent(optionBTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(answerC).addComponent(optionCTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(answerC1).addComponent(optionDTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(note, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addGap(13, 13, 13)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addjButton).addComponent(resButton).addComponent(closejButton))
.addContainerGap(31, Short.MAX_VALUE)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup().addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addContainerGap()));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
pack();
}
private void addjButtonActionPerformed(java.awt.event.ActionEvent evt) {
if (NamejTextArea.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “试题题目不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (optionATextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “选项A不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (optionBTextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “选项B不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (optionCTextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “选项C不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (optionDTextField.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “选项D不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (note.getText().equals(“”)) {
JOptionPane.showMessageDialog(this, “备注不能为空”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
if (!jTextField1.getText().equals(“A”)
&& !(jTextField1.getText().equals(“B”) && !(jTextField1.getText().equals(“C”))
&& !(jTextField1.getText().equals(“D”)) && (jTextField1.getText()).length() > 1)) {
JOptionPane.showMessageDialog(this, “答案必须是’A’,‘B’,‘C’,'D’其中的一项”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
return;
}
FindQuestionDao findQuestion = new FindQuestionDao();
Question question = new Question();
question.setId(Integer.parseInt(idTextField.getText()));
question.setQ_subject(ChDeal.toISO(NamejTextArea.getText()));
question.setQ_answer(ChDeal.toISO(jTextField1.getText()));
question.setOptionA(ChDeal.toISO(optionATextField.getText()));
QuestionType questionType = new QuestionType();// 实例化试题类型
questionType.setQName(ChDeal.toISO(“单选题”));
QuestionType qtype = findQuestion.getQuestionTypeID(questionType);// 获得套题编号
question.setTypeid(qtype.getId());
question.setOptionB(ChDeal.toISO(optionBTextField.getText()));
question.setOptionC(ChDeal.toISO(optionCTextField.getText()));
question.setOptionD(ChDeal.toISO(optionDTextField.getText()));
question.setNote(note.getText());
boolean bool = findQuestion.setQuestionDBbean(question);
if (bool == true) {
JOptionPane.showMessageDialog(this, “信息添加成功”, “信息对话框”, JOptionPane.WARNING_MESSAGE);
dispose();
AdminMainFrame controll = new AdminMainFrame();
controll.setVisible(true);
controll.setLocationRelativeTo(null);
}
}
private void resButtonActionPerformed(java.awt.event.ActionEvent evt) {
NamejTextArea.setText(“”);
jTextField1.setText(“”);
optionATextField.setText(“”);
optionBTextField.setText(“”);
optionCTextField.setText(“”);
optionDTextField.setText(“”);
}
private void closejButtonActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
AdminMainFrame controller = new AdminMainFrame();
controller.setVisible(true);
controller.setBounds(100, 200, 650, 450);
controller.setLocationRelativeTo(null);
}
private void formWindowClosing(java.awt.event.WindowEvent evt) {
dispose();
AdminMainFrame controll = new AdminMainFrame();
controll.setVisible(true);
controll.setLocationRelativeTo(null);
}
private javax.swing.JLabel NameJLabel;
private javax.swing.JButton addjButton;
private javax.swing.JLabel answerB;
private javax.swing.JLabel answerC;
private javax.swing.JLabel answerC1;
private javax.swing.JLabel answerJLabel;
private javax.swing.JButton closejButton;
private javax.swing.JTextField idTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextArea NamejTextArea;
private javax.swing.JTextField jTextField1;
private javax.swing.JLabel messageLabel;
private javax.swing.JTextField optionATextField;
private javax.swing.JTextField optionBTextField;
private javax.swing.JTextField optionCTextField;
private javax.swing.JTextField optionDTextField;
private javax.swing.JTextField note;
private javax.swing.JButton resButton;
}
/*
-
testFrame.java
-
Created on 2008年8月8日, 上午8:30
*/
package com.sjsq.controller;
import javax.swing.JOptionPane;
import com.sjsq.bean.*;
import com.sjsq.dao.FindQuestionDao;
/**
-
@author Administrator
*/
public class AddExamFrame extends javax.swing.JFrame {
/** Creates new form testFrame */
public AddExamFrame() {
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() {
jFrame1 = new javax.swing.JFrame();
noteTextField = new javax.swing.JPanel();
testQuestionMessage = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
qSubjectjTextArea = new javax.swing.JTextArea();
testQuestionId = new javax.swing.JLabel();
qidjTextField = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
qTypejComboBox = new javax.swing.JComboBox();
jSeparator1 = new javax.swing.JSeparator();
answerMessage = new javax.swing.JLabel();
optionA = new javax.swing.JLabel();
optionTextField = new javax.swing.JTextField();
optionB = new javax.swing.JLabel();
optionBTextField = new javax.swing.JTextField();
optionC = new javax.swing.JLabel();
optionCjTextField = new javax.swing.JTextField();
optionD = new javax.swing.JLabel();
optionDTextField = new javax.swing.JTextField();
jSeparator2 = new javax.swing.JSeparator();
answermessage = new javax.swing.JLabel();
qanswerTextField = new javax.swing.JTextField();
saveButton = new javax.swing.JButton();
canceljButton = new javax.swing.JButton();
noteMessage = new javax.swing.JLabel();
noteField = new javax.swing.JTextField();
javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
jFrame1.getContentPane().setLayout(jFrame1Layout);
jFrame1Layout.setHorizontalGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE));
jFrame1Layout.setVerticalGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE));
setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
});
testQuestionMessage.setText(“试题题目:”);
qSubjectjTextArea.setColumns(20);
qSubjectjTextArea.setRows(5);
jScrollPane1.setViewportView(qSubjectjTextArea);
testQuestionId.setText(“试题编号:”);
int id = 0;
FindQuestionDao findQuestion = new FindQuestionDao();
java.util.List questList = findQuestion.findQuestion();
if (questList.size() > 0) {
for (int i = 0; i < questList.size(); i++) {
Question question = questList.get(i);
id = question.getId();
}
}
int ids = findQuestion.findQMid();
int qid = ids + 1;
qidjTextField.setText(“” + qid);
qidjTextField.setEnabled(false);
jLabel1.setText(“试题类型:”);
qTypejComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { “单选题”, “多选题”, “” + “判断题” }));
answerMessage.setText(“题目选项部分,如果是判断题该部分内容可以省略:”);
optionA.setText(“A:”);
optionTextField.setText(“”);
optionB.setText(“B:”);
optionBTextField.setText(“”);
optionC.setText(“C:”);
optionCjTextField.setText(“”);
optionD.setText(“D:”);
optionDTextField.setText(“”);
answermessage.setText(" 答 案:");
qanswerTextField.setText(“”);
saveButton.setText(“保存”);
saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveButtonActionPerformed(evt);
}
});
canceljButton.setText(“重置”);
canceljButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
canceljButtonActionPerformed(evt);
}
});
noteMessage.setText(" 备 注:");
noteField.setText(“”);
javax.swing.GroupLayout noteTextFieldLayout = new javax.swing.GroupLayout(noteTextField);
noteTextField.setLayout(noteTextFieldLayout);
noteTextFieldLayout.setHorizontalGroup(noteTextFieldLayout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(noteTextFieldLayout.createSequentialGroup().addGroup(noteTextFieldLayout
最后
总而言之,面试官问来问去,问的那些Redis知识点也就这么多吧,复习的不够到位,知识点掌握不够熟练,所以面试才会卡壳。将这些Redis面试知识解析以及我整理的一些学习笔记分享出来给大家参考学习
还有更多学习笔记面试资料也分享如下:
ng.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
qSubjectjTextArea = new javax.swing.JTextArea();
testQuestionId = new javax.swing.JLabel();
qidjTextField = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
qTypejComboBox = new javax.swing.JComboBox();
jSeparator1 = new javax.swing.JSeparator();
answerMessage = new javax.swing.JLabel();
optionA = new javax.swing.JLabel();
optionTextField = new javax.swing.JTextField();
optionB = new javax.swing.JLabel();
optionBTextField = new javax.swing.JTextField();
optionC = new javax.swing.JLabel();
optionCjTextField = new javax.swing.JTextField();
optionD = new javax.swing.JLabel();
optionDTextField = new javax.swing.JTextField();
jSeparator2 = new javax.swing.JSeparator();
answermessage = new javax.swing.JLabel();
qanswerTextField = new javax.swing.JTextField();
saveButton = new javax.swing.JButton();
canceljButton = new javax.swing.JButton();
noteMessage = new javax.swing.JLabel();
noteField = new javax.swing.JTextField();
javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
jFrame1.getContentPane().setLayout(jFrame1Layout);
jFrame1Layout.setHorizontalGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE));
jFrame1Layout.setVerticalGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE));
setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
});
testQuestionMessage.setText(“试题题目:”);
qSubjectjTextArea.setColumns(20);
qSubjectjTextArea.setRows(5);
jScrollPane1.setViewportView(qSubjectjTextArea);
testQuestionId.setText(“试题编号:”);
int id = 0;
FindQuestionDao findQuestion = new FindQuestionDao();
java.util.List questList = findQuestion.findQuestion();
if (questList.size() > 0) {
for (int i = 0; i < questList.size(); i++) {
Question question = questList.get(i);
id = question.getId();
}
}
int ids = findQuestion.findQMid();
int qid = ids + 1;
qidjTextField.setText(“” + qid);
qidjTextField.setEnabled(false);
jLabel1.setText(“试题类型:”);
qTypejComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { “单选题”, “多选题”, “” + “判断题” }));
answerMessage.setText(“题目选项部分,如果是判断题该部分内容可以省略:”);
optionA.setText(“A:”);
optionTextField.setText(“”);
optionB.setText(“B:”);
optionBTextField.setText(“”);
optionC.setText(“C:”);
optionCjTextField.setText(“”);
optionD.setText(“D:”);
optionDTextField.setText(“”);
answermessage.setText(" 答 案:");
qanswerTextField.setText(“”);
saveButton.setText(“保存”);
saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveButtonActionPerformed(evt);
}
});
canceljButton.setText(“重置”);
canceljButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
canceljButtonActionPerformed(evt);
}
});
noteMessage.setText(" 备 注:");
noteField.setText(“”);
javax.swing.GroupLayout noteTextFieldLayout = new javax.swing.GroupLayout(noteTextField);
noteTextField.setLayout(noteTextFieldLayout);
noteTextFieldLayout.setHorizontalGroup(noteTextFieldLayout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(noteTextFieldLayout.createSequentialGroup().addGroup(noteTextFieldLayout
最后
总而言之,面试官问来问去,问的那些Redis知识点也就这么多吧,复习的不够到位,知识点掌握不够熟练,所以面试才会卡壳。将这些Redis面试知识解析以及我整理的一些学习笔记分享出来给大家参考学习
还有更多学习笔记面试资料也分享如下:
[外链图片转存中…(img-gKuj76bK-1725873158548)]