基于java+mysql的swing+mysql考试系统java基础gui(java+gui)

该博客介绍了基于Java和MySQL的Swing考试系统。运行环境要求Java≥8、MySQL≥5.7,开发工具可选eclipse等。适用于课程设计等。系统功能包括所属课程、题目管理、学生管理、试卷管理及时间控制等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

请添加图片描述
基于java+mysql的swing+mysql考试系统java基础gui(java+gui)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于java+mysql的Swing+MySQL考试系统java基础gui(java+gui)

功能简介:

所属课程、题目内容、题目选项、题目答案、题目等级、学生管理、试卷管理、题目管理、时间控制


/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class TitleManageFrame extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel jPanel1;
	private JButton jButton1;
	private JButton jButton4;
	private JScrollPane jScrollPane1;
	private JButton jButton5;
	private JButton jButton3;
	private JButton jButton2;
	private JTable jTable1;
	private String[][] listTitle;
	// 注入TitleManage
	private static TitleManage titleManage = new TitleManageImp();

	{
		// Set Look & Feel
		try {
			javax.swing.UIManager
					.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Auto-generated main method to display this JFrame
	 */

	public static String[][] titleList() {
				jCheckBox3 = new Checkbox("C", checkboxGroup, false);
				jPanel1.add(jCheckBox3);
				// jCheckBox3.setText("C");
				jCheckBox3.setBounds(456, 361, 33, 19);
			}
			{
				jLabel2 = new JLabel();
				jPanel1.add(jLabel2);
				jPanel1.add(getJCheckBox4());
				jPanel1.add(getJButton5());
				jPanel1.add(getJLabel3());
				jLabel2.setText("选择");
				jLabel2.setBounds(264, 362, 41, 17);
			}
		}

		// 开始做题事件
		jButton1.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				username = userManage.findById(uid).getName();
				time = System.currentTimeMillis();

				// 取到试卷
				Paper paper = paperManage.findById(uid);
				strTitle = paper.getListTitle().split(",");
				// 题号
				int tid1 = Integer.parseInt(strTitle[0]);
				

				showTitle(tid1);
				
				
				jButton1.setEnabled(false);
				jButton5.setEnabled(false);
				th.start();

			}
		});
		// 下一题
		jButton2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// 题号
				int tid1 = Integer.parseInt(strTitle[i]);
				// 保存用户答案
				mapAnswer
				getContentPane().add(jPanel1);
				jPanel1.setBounds(0, -100, 562, 458);
				jPanel1.setLayout(null);
				{
					jLabel1 = new JLabel();
					jPanel1.add(jLabel1);
					jLabel1.setText("\u9898\u76ee\u5185\u5bb9");
					jLabel1.setBounds(67, 48, 91, 33);
				}
				{
					jLabel7 = new JLabel();
					jPanel1.add(jLabel7);
					jLabel7.setText("\u5b66\u751f\u59d3\u540d");
					jLabel7.setBounds(135, 195, 68, 17);
				}
				{
					jButton1 = new JButton();
					jPanel1.add(jButton1);
					jButton1.setText("\u4fee\u6539");
					jButton1.setBounds(226, 361, 67, 24);
				}
				{
					jButton2 = new JButton();
					jPanel1.add(jButton2);
					jButton2.setText("\u6e05\u7a7a");
					jButton2.setBounds(351, 361, 68, 24);
				}
				{
					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);
				}
				{
					jLabel2 = new JLabel();
					jPanel1.add(jLabel2);
					jLabel2.setText("\u5b66\u751f\u7f16\u53f7");
					jLabel2.setBounds(135, 123, 91, 33);
			// 增加题目事件
			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();
					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();
		}

		jButton2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				jTextArea1.setText("");
				jTextField1.setText("");
				jTextField2.setText("");
				jTextField3.setText("");
				jTextField4.setText("");
				jComboBox1.setSelectedIndex(0);
				jComboBox2.setSelectedIndex(2);
				jComboBox3.setSelectedIndex(4);

				.addGroup(
						jPanel1Layout.createParallelGroup(
								GroupLayout.Alignment.BASELINE).addComponent(
								jPasswordField1,
								GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE).addComponent(
								jLabel3, GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE)).addGap(55)
				.addGroup(
						jPanel1Layout.createParallelGroup(
								GroupLayout.Alignment.BASELINE).addComponent(
								jButton1, GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE).addComponent(
								jButton2, GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE)).addContainerGap(
						92, 92));
		jPanel1Layout
				.setHorizontalGroup(jPanel1Layout
						.createSequentialGroup()
						.addContainerGap(92, 92)
						.addGroup(
								jPanel1Layout
										.createParallelGroup()
										.addGroup(
												jPanel1Layout
														.createSequentialGroup()
														.addGroup(
																jPanel1Layout
																		.createParallelGroup()
																		.addComponent(
																				jLabel3,
																				GroupLayout.Alignment.LEADING,
																				GroupLayout.PREFERRED_SIZE,
		jButton2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				jTextField1.setText("");
			}
		});
		jLabel1.setFont(new java.awt.Font("微软雅黑", 0, 18));
		jLabel1.setText("           \u767b\u9646\u754c\u9762");
		{
			jPasswordField1 = new JPasswordField();
		}

		jLabel2.setText("编号");

		jLabel3.setText("密码");

		jTextField1.setFont(new java.awt.Font("Dotum", 0, 14));
		jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup()
				.addComponent(jLabel1, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addGap(43).addGroup(
						jPanel1Layout.createParallelGroup(
								GroupLayout.Alignment.BASELINE).addComponent(
								jTextField1, GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE).addComponent(
								jLabel2, GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE)).addGap(24)
				.addGroup(
						jPanel1Layout.createParallelGroup(
								GroupLayout.Alignment.BASELINE).addComponent(
								jPasswordField1,
								GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE).addComponent(
								jLabel3, GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE)).addGap(55)
				.addGroup(
						jPanel1Layout.createParallelGroup(
								GroupLayout.Alignment.BASELINE).addComponent(
								jButton1, GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE).addComponent(
								jButton2, GroupLayout.Alignment.BASELINE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.PREFERRED_SIZE)).addContainerGap(
						.getPassword());
				if (null == jTextField1.getText() || null == passwordInfo) {
					JOptionPane.showMessageDialog(LoginFrame.this, "请输入用户名和密码");
				}
				User user = userManage.findById(uid);
				// System.out.println(user.getName());
				String password = user.getPassword();
				// System.out.println(MD5Util.md5(passwordInfo).equals(password));
				if (passwordInfo.equals(password)) {

					setVisible(false);
					if ("admin".equals(user.getName())) {
						JOptionPane
								.showMessageDialog(LoginFrame.this, "welcome admin");
						new ServerClient();
					} else {
						String name = userManage.findById(uid).getName();
						JOptionPane.showMessageDialog(LoginFrame.this, "welcome "
								+ name);
						new WelcomeFrame(uid);
					}

				} else
					JOptionPane.showMessageDialog(LoginFrame.this, "用户名不存在获密码错误");

			}
		});

		jButton2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				new ChangePasswordFrame();
			}
		});
		// 请空密码和用户名
		jButton2.setText("\u4fee\u6539\u5bc6\u7801");
		jButton2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				jTextField1.setText("");
			}
		});
		jLabel1.setFont(new java.awt.Font("微软雅黑", 0, 18));
		jLabel1.setText("           \u767b\u9646\u754c\u9762");
//				int length = title7.length;
//				title7 = Arrays.copyOf(title7, length + 1);
//			}
//			if (title.getLevel() == 8) {
//				title8[n8++] = title.getTid();
//				int length = title8.length;
//				title8 = Arrays.copyOf(title8, length + 1);
//			}
//			if (title.getLevel() == 9) {
//				title9[n9++] = title.getTid();
//				int length = title9.length;
//				title9 = Arrays.copyOf(title9, length + 1);
//			}
//			if (title.getLevel() == 10) {
//				title10[n10++] = title.getTid();
//				int length = title10.length;
//				title10 = Arrays.copyOf(title10, length + 1);
//			}

		}
		// 去掉数组最后一个0元素(数组扩容的后遗症)
		int len1 = title1.length;
		title1 = Arrays.copyOfRange(title1, 0, len1 - 1);

		int len2 = title2.length;
		title2 = Arrays.copyOfRange(title2, 0, len2 - 1);

//		int len3 = title3.length;
//		title3 = Arrays.copyOfRange(title3, 0, len3 - 1);
//
//		int len4 = title4.length;
//		title4 = Arrays.copyOfRange(title4, 0, len4 - 1);
//
//		int len5 = title5.length;
//		title5 = Arrays.copyOfRange(title5, 0, len5 - 1);
//
//		int len6 = title6.length;
//		title6 = Arrays.copyOfRange(title6, 0, len6 - 1);
//
//		int len7 = title7.length;
//		title7 = Arrays.copyOfRange(title7, 0, len7 - 1);
//

			if (title.getLevel() == 2) {
				title2[n2++] = title.getTid();
				int length = title2.length;
				title2 = Arrays.copyOf(title2, length + 1);
			}

//			if (title.getLevel() == 3) {
//				title3[n3++] = title.getTid();
//				int length = title3.length;
//				title3 = Arrays.copyOf(title3, length + 1);
//			}
//
//			if (title.getLevel() == 4) {
//				title4[n4++] = title.getTid();
//				int length = title4.length;
//				title4 = Arrays.copyOf(title4, length + 1);
//			}
//
//			if (title.getLevel() == 5) {
//				title5[n5++] = title.getTid();
//				int length = title5.length;
//				title5 = Arrays.copyOf(title5, length + 1);
//			}
//			if (title.getLevel() == 6) {
//				title6[n6++] = title.getTid();
//				int length = title6.length;
//				title6 = Arrays.copyOf(title6, length + 1);
//			}
//			if (title.getLevel() == 7) {
//				title7[n7++] = title.getTid();
//				int length = title7.length;
//				title7 = Arrays.copyOf(title7, length + 1);
//			}
//			if (title.getLevel() == 8) {
//				title8[n8++] = title.getTid();
//				int length = title8.length;
//				title8 = Arrays.copyOf(title8, length + 1);
//			}
//			if (title.getLevel() == 9) {
//				title9[n9++] = title.getTid();
//				int length = title9.length;
//				title9 = Arrays.copyOf(title9, length + 1);
//			}

	@Override
	public Title update(Title title) {
		int id = title.getTid();
		String question = title.getQuestion();
		String option = title.getOption();
		String key = title.getKey();
		int level=title.getLevel();
		int score=title.getScore();
		String course=title.getCourse();
		String updateSql = "update t_title set question='" + question
				+ "',toption='" + option + "',tkey='" + key + "',level="+level+",score="+score+",course='" +course+"' where tid="
				+ id;
		System.out.println(updateSql);
		Connection con;
		try {
			con = DBcon.getDBcon().getConnection();
			PreparedStatement ps = con.prepareStatement(updateSql);
			ps.executeUpdate();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return title;
	}

	
	public List<Title> findAll() {

		List<Title> listTitle = new ArrayList<Title>();

		String findSql = "select * from t_title";
		try {

			Connection con = DBcon.getDBcon().getConnection();
			PreparedStatement ps = con.prepareStatement(findSql);

			ResultSet rs = ps.executeQuery();

			
			while (rs.next()) {
				Title title =new Title();
				
				title.setTid(rs.getInt(1));
				title.setQuestion(rs.getString(2));
				title.setOption(rs.getString(3));
				title.setKey(rs.getString(4));
				title.setLevel(rs.getInt(5));
				title.setScore(rs.getInt(6));
				title.setCourse(rs.getString(7));
				listTitle.add(title);
				
			}
	}

}

public class ImportTitle {

	// 注入TitleManageImp
	private TitleManage titleManage = new TitleManageImp();

	// 得到User
	public List<Title> getTitles() throws IOException {

		List<Title> list1 = new ArrayList<Title>();
		InputStreamReader isr = new InputStreamReader(new FileInputStream(
				new File("title.txt")));

		BufferedReader br = new BufferedReader(isr);

		String str = null;
		while (true) {

			str = br.readLine();
			if (str == null)
				break;
			String[] strUser = str.split(":");
			Title title = new Title();
System.out.println(Arrays.toString(strUser));
			String question = strUser[0];
			String option = strUser[1];
			String key = strUser[2].trim();
			//System.out.println(strUser[3]);
			System.out.println(strUser[3]);
			int level = Integer.parseInt(strUser[3].trim());
			int score = Integer.parseInt(strUser[4].trim());
			String course=strUser[5];

			title.setQuestion(question);
			title.setOption(option);

					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();
		}

		jButton2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				jTextArea1.setText("");
				jTextField1.setText("");
				jTextField2.setText("");
				jTextField3.setText("");
				jTextField4.setText("");
				jComboBox1.setSelectedIndex(0);
				jComboBox2.setSelectedIndex(2);
				jComboBox3.setSelectedIndex(4);

			}
		});

	}

}

					jPanel1.add(jComboBox3);
					System.out.println(title.getKey());
					jComboBox3.setSelectedItem(title.getKey());
					jComboBox3.setModel(jComboBox3Model);
					jComboBox3.setBounds(168, 217, 98, 21);
				}
				{
					ComboBoxModel jComboBox4Model = new DefaultComboBoxModel(
							new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
					jComboBox4 = new JComboBox();
					jPanel1.add(jComboBox4);
					jComboBox4.setModel(jComboBox4Model);
					jComboBox4.setBounds(168, 259, 98, 21);
				}
				{
					ComboBoxModel jComboBox5Model = 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 });
					jComboBox5 = new JComboBox();
					jPanel1.add(jComboBox5);
					jComboBox5.setModel(jComboBox5Model);
					jComboBox5.setBounds(168, 294, 98, 21);
				}
				{
					jLabel3 = new JLabel();
					jPanel1.add(jLabel3);
					jLabel3.setText("\u6240\u5c5e\u8bfe\u7a0b");
					jLabel3.setBounds(63, 126, 70, 14);
				}
				{
					ComboBoxModel jComboBox1Model = 
						new DefaultComboBoxModel(
								new String[] {"JAVA SE", "MySql", "离散数学", "操作系统",
										"计算机网络", "编译原理", "C语言", "C++", "汇编语言" });
					jComboBox1 = new JComboBox();
					jPanel1.add(jComboBox1);
					jComboBox1.setModel(jComboBox1Model);
					jComboBox1.setBounds(168, 119, 98, 21);
				}
			}
			pack();
			e.printStackTrace();
		}
	}

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ChangePasswordFrame inst = new ChangePasswordFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ChangePasswordFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1);
				jPanel1.setBounds(0, 0, 485, 343);
				jPanel1.setLayout(null);
				{
					jButton1 = new JButton();
					jPanel1.add(jButton1);
					jButton1.setText("\u786e\u8ba4");
					jButton1.setBounds(182, 261, 52, 30);
				}
				{
					jButton2 = new JButton();
					jPanel1.add(jButton2);
					jButton2.setText("\u91cd\u7f6e");
					jButton2.setBounds(282, 261, 52, 30);
					jButton2.setOpaque(true);
				}
				{
					jLabel2 = new JLabel();
					jPanel1.add(jLabel2);
					jLabel2.setText("       \u4fee\u6539\u5bc6\u7801");
					jLabel2.setBounds(140, 20, 203, 45);
					jLabel2.setOpaque(true);
					jLabel2.setFont(new java.awt.Font("楷体",0,18));
				}
				{
					jTextField2.setBounds(436, 147, 131, 24);
				}
				{
					jLabel4 = new JLabel();
					jPanel1.add(jLabel4);
					jLabel4.setText("C");
					jLabel4.setBounds(147, 179, 14, 16);
				}
				{
					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();
					jPanel1.add(jButton1);
					jButton1.setText("\u589e\u52a0");
					jButton1.setBounds(188, 402, 67, 24);
				}
				{
					jButton2 = new JButton();
					jPanel1.add(jButton2);
					jButton2.setText("\u6e05\u7a7a");
					jButton2.setBounds(365, 402, 68, 24);
				}
				{
					jTextField4 = new JTextField();
					}
					else
						JOptionPane.showMessageDialog(jButton1, "原始密码错误");
				}
			});
			jButton2.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					// TODO Auto-generated method stub
					jPasswordField1.setText("");
					jPasswordField2.setText("");
					
				}
			});
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}

public class TitleDAO implements ITitleDAO {

	public void delete(Title title) {
		int tid = title.getTid();
		String delSql = "delete from t_title where tid=" + tid;

		try {
			Connection con = DBcon.getDBcon().getConnection();
			PreparedStatement ps = con.prepareStatement(delSql);
			ps.executeUpdate();
		} catch (Exception e) {
			e.printStackTrace();
		}

			}
		});
		// 下一题
		jButton2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// 题号
				int tid1 = Integer.parseInt(strTitle[i]);
				// 保存用户答案
				mapAnswer
						.put(i, checkboxGroup.getSelectedCheckbox().getLabel());
				i++;
				jLabel1.setText("课程:" + paperManage.findById(uid).getCourse()
						+ ";" + username + "你的答题进度为" + i + "/"
						+ strTitle.length);
				
				checkboxGroup.getSelectedCheckbox();

				showTitle(tid1);

				if ("A".equals(mapAnswer.get(i))) {
					jCheckBox1.setState(true);
				}

				if ("B".equals(mapAnswer.get(i))) {
					jCheckBox2.setState(true);
				}

				if ("C".equals(mapAnswer.get(i))) {
					jCheckBox3.setState(true);
				}

				if ("D".equals(mapAnswer.get(i))) {
					jCheckBox4.setState(true);
				}

				jButton5.setEnabled(true);
				if (i == strTitle.length) {
					jButton2.setEnabled(false);
				}

			}
		});
		// 上一题的事件
		jButton5.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// 保存用户答案
				mapAnswer
						.put(i, checkboxGroup.getSelectedCheckbox().getLabel());

请添加图片描述

请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值