基于java+swing+gui的考试管理(java+Gui)
功能简介:
所属课程、题目内容、题目选项、题目答案、题目等级、学生管理、试卷管理、题目管理、时间控制
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
![](https://i-blog.csdnimg.cn/blog_migrate/7a7585bc77ea31dc78392dcc90880030.png)
*/
/**
*
*/
private static final long serialVersionUID = 1L;
/** Creates new form ServerClient */
public ServerClient() {
initComponents();
this.setVisible(true);
}
/**
* This method is called from within the constructor to initialize the form.
67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100 });
jComboBox3 = new JComboBox();
jComboBox3.setMaximumRowCount(5);
jPanel1.add(jComboBox3);
jComboBox3.setModel(jComboBox3Model);
jComboBox3.setBounds(176, 323, 73, 24);
}
{
jLabel12 = new JLabel();
jPanel1.add(jLabel12);
jLabel12.setText("\u6240\u5c5e\u8bfe\u7a0b");
jLabel12.setBounds(67, 116, 59, 17);
}
{
ComboBoxModel jComboBox4Model =
}
{
jTextField4 = new JTextField();
jPanel1.add(jTextField4);
jTextField4.setText(paper + "");
jTextField4.setEditable(false);
jTextField4.setBounds(238, 304, 181, 23);
}
}
pack();
this.setSize(552, 391);
setLocationRelativeTo(null);
setVisible(true);
jTextField1.setEditable(false);
jTextField4.setEditable(false);
// 修改密码事件
jButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String name = jTextField2.getText();
String password = jTextField3.getText();
User user1 = new User();
pack();
this.setSize(734, 526);
setLocationRelativeTo(null);
setVisible(true);
// 增加题目事件
jButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String question = jTextArea1.getText();
// System.out.println(question);
String option = "A:" + jTextField1.getText() + ",B:"
+ jTextField2.getText() + ",C:"
+ jTextField3.getText() + ",D:"
+ jTextField4.getText();
String key = (String) jComboBox2.getSelectedItem();
int level = (Integer) (jComboBox1.getSelectedItem());
int score = (Integer) jComboBox3.getSelectedItem();
String course = (String) jComboBox4.getSelectedItem();
+ jTextField4.getText();
String key = (String) jComboBox2.getSelectedItem();
int level = (Integer) (jComboBox1.getSelectedItem());
int score = (Integer) jComboBox3.getSelectedItem();
String course = (String) jComboBox4.getSelectedItem();
System.out.println(level);
Title title = new Title();
// title.setTid(1);
title.setQuestion(question);
title.setOption(option);
title.setKey(key);
Short.MAX_VALUE));
layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(
jLabel1, 0, 665, Short.MAX_VALUE));
jLabel1.setIcon(new ImageIcon(getClass().getResource("exam1.jpg")));
pack();
// 置中
this.setLocationRelativeTo(null);
// 固定大小
setResizable(false);
}// </editor-fold>
// GEN-END:initComponents
/**
* @param args
* the command line arguments
*/
// GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private JLabel jLabel1;
private javax.swing.JMenuItem jMenuItem1;
private JLabel jLabel1;
private JLabel jLabel10;
private JLabel jLabel7;
private JLabel jLabel8;
private JPanel jPanel1;
private User user;
private int paper;
/**
*
*/
// 注入UserManage
private static UserManage userManage = new UserManageImp();
public UpdateStudentFrame(User user, int paper2) {
super();
int score = (Integer) jComboBox3.getSelectedItem();
String course = (String) jComboBox4.getSelectedItem();
System.out.println(level);
Title title = new Title();
// title.setTid(1);
title.setQuestion(question);
title.setOption(option);
title.setKey(key);
title.setLevel(level);
title.setScore(score);
title.setCourse(course);
titleManage.save(title);
JOptionPane.showMessageDialog(AddTitleFrame.this, "add success!!!");
}
});
} catch (Exception e) {
// add your error handling code here
e.printStackTrace();
}
jTextArea1 = new JTextArea();
jPanel1.add(jTextArea1);
jTextArea1.setBounds(176, 22, 391, 86);
}
{
jLabel2 = new JLabel();
jPanel1.add(jLabel2);
jLabel2.setText("A");
jLabel2.setBounds(147, 150, 23, 17);
}
{
jTextField1 = new JTextField();
jPanel1.add(jTextField1);
jTextField1.setBounds(195, 147, 131, 24);
}
{
jLabel3 = new JLabel();
jPanel1.add(jLabel3);
jLabel3.setText("B");
jLabel3.setBounds(392, 150, 26, 17);
new DefaultComboBoxModel(
new String[] {"JAVA SE", "MySql", "离散数学", "操作系统",
"计算机网络", "编译原理", "C语言", "C++", "汇编语言"});
jComboBox4 = new JComboBox();
jPanel1.add(jComboBox4);
jComboBox4.setModel(jComboBox4Model);
jComboBox4.setBounds(180, 117, 107, 24);
}
}
pack();
this.setSize(734, 526);
setLocationRelativeTo(null);
setVisible(true);
// 增加题目事件
jButton1.addActionListener(new ActionListener() {
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private JLabel jLabel1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
// End of variables declaration//GEN-END:variables
}
学生页面服务:
public class UpdateStudentFrame extends javax.swing.JFrame {
private static final long serialVersionUID = 1L;
/**
* Auto-generated main method to display this JFrame
// GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
int var = JOptionPane.showConfirmDialog(ServerClient.this,
"确定离开吗?");
if (var == JOptionPane.YES_OPTION) {
System.exit(0);
}
}
});
jMenuBar1 = new javax.swing.JMenuBar();
}
{
jLabel10 = new JLabel();
jPanel1.add(jLabel10);
jLabel10.setText("\u9898\u76ee\u5206\u6570");
jLabel10.setBounds(67, 327, 68, 17);
jLabel10.setOpaque(true);
}
{
jLabel11 = new JLabel();
jPanel1.add(jLabel11);
jLabel11.setText("0---100\u4e4b\u95f4");
jLabel11.setBounds(267, 327, 137, 17);
jLabel11.setOpaque(true);
}
{
jTextField3 = new JTextField();
jPanel1.add(jTextField3);
jTextField3.setBounds(195, 176, 131, 24);
}
{
ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
{
jLabel5 = new JLabel();
jPanel1.add(jLabel5);
jLabel5.setText("D");
jLabel5.setBounds(392, 181, 20, 17);
}
{
jLabel6 = new JLabel();
jPanel1.add(jLabel6);
jLabel6.setText("\u9898\u76ee\u9009\u9879");
jLabel6.setBounds(67, 150, 59, 17);
}
{
jLabel7 = new JLabel();
jPanel1.add(jLabel7);
jLabel7.setText("\u9898\u76ee\u7b54\u6848");
jLabel7.setBounds(67, 229, 68, 17);
}
{
getContentPane());
getContentPane().setLayout(layout);
{
jLabel1 = new JLabel();
}
layout.setVerticalGroup(layout.createSequentialGroup()
.addContainerGap().addComponent(jLabel1, 0, 398,
Short.MAX_VALUE));
layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(
jLabel1, 0, 665, Short.MAX_VALUE));
jLabel1.setIcon(new ImageIcon(getClass().getResource("exam1.jpg")));
private JLabel jLabel1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
// End of variables declaration//GEN-END:variables
}
学生页面服务:
public class UpdateStudentFrame extends javax.swing.JFrame {
private static final long serialVersionUID = 1L;
/**
* Auto-generated main method to display this JFrame
*/
private JButton jButton1;
private JTextField jTextField1;
private JTextField jTextField2;
private JTextField jTextField4;
private JComboBox jComboBox4;
/**
*
*/
// 注入Service
private TitleManage titleManage = new TitleManageImp();
public AddTitleFrame() {
super();
initGUI();
}
public JTextField getJTextField2() {
return jTextField2;
}
private void initGUI() {
try {
}
{
jLabel5 = new JLabel();
jPanel1.add(jLabel5);
jLabel5.setText("D");
jLabel5.setBounds(392, 181, 20, 17);
}
{
jLabel6 = new JLabel();
jPanel1.add(jLabel6);
jLabel6.setText("\u9898\u76ee\u9009\u9879");
jLabel6.setBounds(67, 150, 59, 17);
}
{
jLabel7 = new JLabel();
jPanel1.add(jLabel7);
jLabel7.setText("\u9898\u76ee\u7b54\u6848");
jLabel7.setBounds(67, 229, 68, 17);
}
{
jButton1 = new JButton();
new String[] { "A", "B", "C", "D" });
jComboBox2 = new JComboBox();
jPanel1.add(jComboBox2);
jComboBox2.setModel(jComboBox2Model);
jComboBox2.setBounds(176, 225, 73, 24);
}
{
ComboBoxModel jComboBox3Model = new DefaultComboBoxModel(
new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100 });
jComboBox3 = new JComboBox();
jComboBox3.setMaximumRowCount(5);
title.setKey(key);
title.setLevel(level);
title.setScore(score);
title.setCourse(course);
titleManage.save(title);
JOptionPane.showMessageDialog(AddTitleFrame.this, "add success!!!");
}
});
} catch (Exception e) {
// add your error handling code here
e.printStackTrace();
}
jButton2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jTextArea1.setText("");
jTextField1.setText("");
@Override
public void actionPerformed(ActionEvent e) {
String question = jTextArea1.getText();
// System.out.println(question);
String option = "A:" + jTextField1.getText() + ",B:"
+ jTextField2.getText() + ",C:"
+ jTextField3.getText() + ",D:"
+ jTextField4.getText();
String key = (String) jComboBox2.getSelectedItem();
int level = (Integer) (jComboBox1.getSelectedItem());
int score = (Integer) jComboBox3.getSelectedItem();
String course = (String) jComboBox4.getSelectedItem();
System.out.println(level);
Title title = new Title();
// title.setTid(1);
title.setQuestion(question);
String password = jTextField3.getText();
User user1 = new User();
user1.setUid(user.getUid());
user1.setName(name);
user1.setPassword(password);
Paper paper1 = new Paper();
if (paper == 0) {
paper1 = null;
userManage.update(user1);
} else {
paper1.setPid(paper);
user1.setPaper(paper1);
userManage.update(user1);
}
JOptionPane
}
{
jLabel3 = new JLabel();
jPanel1.add(jLabel3);
jLabel3.setText("B");
jLabel3.setBounds(392, 150, 26, 17);
}
{
jTextField2 = new JTextField();
jPanel1.add(getJTextField2());
jTextField2.setBounds(436, 147, 131, 24);
}
{
jLabel4 = new JLabel();
jPanel1.add(jLabel4);
jLabel4.setText("C");
jLabel4.setBounds(147, 179, 14, 16);
}
}
});
} catch (Exception e) {
// add your error handling code here
e.printStackTrace();
}
jButton2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jTextArea1.setText("");
jTextField1.setText("");
jTextField2.setText("");
private javax.swing.JMenuItem jMenuItem4;
// End of variables declaration//GEN-END:variables
}
学生页面服务:
public class UpdateStudentFrame extends javax.swing.JFrame {
private static final long serialVersionUID = 1L;
/**
* Auto-generated main method to display this JFrame
*/
private JButton jButton1;
private JLabel jLabel2;
private JTextField jTextField4;
private JTextField jTextField3;
private JTextField jTextField2;
private JTextField jTextField1;
jLabel8 = new JLabel();
jPanel1.add(jLabel8);
jLabel8.setText("\u5b66\u751f\u5bc6\u7801");
jLabel8.setBounds(135, 253, 68, 17);
}
{
jLabel10 = new JLabel();
jPanel1.add(jLabel10);
jLabel10.setText("\u8bd5\u5377\u7f16\u53f7");
jLabel10.setBounds(135, 307, 68, 17);
jLabel10.setOpaque(true);
}
{
}
JOptionPane
.showMessageDialog(UpdateStudentFrame.this, "update success!!!");
}
});
} catch (Exception e) {
// add your error handling code here
e.printStackTrace();
}
jButton2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jTextField3.setText("");
}
});
}
}
适用
课程设计,大作业,毕业设计,项目练习,学习演示等