parent
4c8aa575a0
commit
7a05b95c91
@ -1,3 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
Main-Class: Math_learning_app
|
|
||||||
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
import Service.User_service;
|
|
||||||
import View.Login_frame;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class Math_learning_app {
|
|
||||||
private static User_service userService;
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
initializeServices();
|
|
||||||
SwingUtilities.invokeLater(Math_learning_app::showLoginFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void initializeServices() {
|
|
||||||
userService = new User_service();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showLoginFrame() {
|
|
||||||
Login_frame loginFrame = new Login_frame(userService);
|
|
||||||
loginFrame.setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,173 +0,0 @@
|
|||||||
package View;
|
|
||||||
|
|
||||||
import Base.Exam_result;
|
|
||||||
import Base.Question;
|
|
||||||
import Service.Deal_file;
|
|
||||||
import Service.Exam_service;
|
|
||||||
import Service.User_service;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
public class Exam_frame extends JFrame {
|
|
||||||
private Exam_service examService;
|
|
||||||
private User_service userService;
|
|
||||||
private String email;
|
|
||||||
private JLabel questionLabel;
|
|
||||||
private JRadioButton[] optionButtons;
|
|
||||||
private ButtonGroup buttonGroup;
|
|
||||||
private JLabel progressLabel;
|
|
||||||
private JButton previousButton;
|
|
||||||
private JButton nextButton;
|
|
||||||
|
|
||||||
public Exam_frame(Exam_service examService, User_service userService, String email) {
|
|
||||||
this.examService = examService;
|
|
||||||
this.userService = userService;
|
|
||||||
this.email = email;
|
|
||||||
initializeUI();
|
|
||||||
showQuestion();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeUI() {
|
|
||||||
setTitle("考试");
|
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
setSize(600, 400);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
setResizable(false);
|
|
||||||
|
|
||||||
// 主面板
|
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
|
|
||||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
|
||||||
|
|
||||||
// 进度标签
|
|
||||||
progressLabel = new JLabel();
|
|
||||||
updateProgress();
|
|
||||||
mainPanel.add(progressLabel, BorderLayout.NORTH);
|
|
||||||
|
|
||||||
// 题目面板
|
|
||||||
JPanel questionPanel = new JPanel(new BorderLayout());
|
|
||||||
questionLabel = new JLabel();
|
|
||||||
questionLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
||||||
questionPanel.add(questionLabel, BorderLayout.NORTH);
|
|
||||||
|
|
||||||
// 选项面板
|
|
||||||
JPanel optionsPanel = new JPanel(new GridLayout(4, 1, 10, 10));
|
|
||||||
optionButtons = new JRadioButton[4];
|
|
||||||
buttonGroup = new ButtonGroup();
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
optionButtons[i] = new JRadioButton();
|
|
||||||
optionButtons[i].setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
||||||
buttonGroup.add(optionButtons[i]);
|
|
||||||
optionsPanel.add(optionButtons[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
questionPanel.add(optionsPanel, BorderLayout.CENTER);
|
|
||||||
mainPanel.add(questionPanel, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
// 按钮面板
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout());
|
|
||||||
previousButton = new JButton("上一题");
|
|
||||||
nextButton = new JButton("下一题");
|
|
||||||
|
|
||||||
buttonPanel.add(previousButton);
|
|
||||||
buttonPanel.add(nextButton);
|
|
||||||
|
|
||||||
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
|
||||||
|
|
||||||
// 添加事件监听器
|
|
||||||
previousButton.addActionListener(new PreviousListener());
|
|
||||||
nextButton.addActionListener(new NextListener());
|
|
||||||
|
|
||||||
add(mainPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showQuestion() {
|
|
||||||
Question currentQuestion = examService.get_now_question();
|
|
||||||
if (currentQuestion == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
questionLabel.setText(currentQuestion.getContent());
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
String options = currentQuestion.getOptions(i);
|
|
||||||
optionButtons[i].setText(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否已经回答过该题
|
|
||||||
Integer userAnswer = examService.get_user_answer(examService.get_now_index());
|
|
||||||
if (userAnswer != null && userAnswer!=-1) {
|
|
||||||
optionButtons[userAnswer].setSelected(true);
|
|
||||||
} else {
|
|
||||||
buttonGroup.clearSelection();
|
|
||||||
}
|
|
||||||
updateProgress();
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateProgress() {
|
|
||||||
int current = examService.get_now_index() + 1;
|
|
||||||
int total = examService.get_paper().size();
|
|
||||||
progressLabel.setText("进度: " + current + "/" + total);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateButtons() {
|
|
||||||
int currentIndex = examService.get_now_index();
|
|
||||||
int total = examService.get_paper().size();
|
|
||||||
|
|
||||||
previousButton.setEnabled(currentIndex > 0);
|
|
||||||
nextButton.setText(currentIndex < total - 1 ? "下一题" : "提交");
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PreviousListener implements ActionListener {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// 保存当前答案
|
|
||||||
saveAnswer();
|
|
||||||
if (examService.pre_one()) {
|
|
||||||
showQuestion();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class NextListener implements ActionListener {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
boolean hasNext = examService.next_one(getSelectedOption());
|
|
||||||
if (hasNext) {
|
|
||||||
showQuestion();
|
|
||||||
} else {
|
|
||||||
if (!examService.check_finished()){
|
|
||||||
JOptionPane.showMessageDialog(Exam_frame.this,
|
|
||||||
"有题目未完成", "错误", JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Exam_result result = examService.calculate_result();
|
|
||||||
openResultFrame(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveAnswer() {
|
|
||||||
int selected = getSelectedOption();
|
|
||||||
if (selected != -1) {
|
|
||||||
examService.change_answer(examService.get_now_index(), selected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getSelectedOption() {
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
if (optionButtons[i].isSelected()) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openResultFrame(Exam_result result) {
|
|
||||||
Result_frame resultFrame = new Result_frame(examService, result , userService, email);
|
|
||||||
resultFrame.setVisible(true);
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,104 +0,0 @@
|
|||||||
package View;
|
|
||||||
|
|
||||||
import Service.User_service;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
public class Login_frame extends JFrame {
|
|
||||||
private User_service userService;
|
|
||||||
private JTextField idField;
|
|
||||||
private JPasswordField passwordField;
|
|
||||||
|
|
||||||
public Login_frame(User_service userService) {
|
|
||||||
this.userService = userService;
|
|
||||||
initializeUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeUI() {
|
|
||||||
setTitle("登录");
|
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
setSize(400, 350);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
setResizable(false);
|
|
||||||
|
|
||||||
// 主面板
|
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
|
|
||||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
|
||||||
|
|
||||||
// 标题
|
|
||||||
JLabel titleLabel = new JLabel("数学学习软件", JLabel.CENTER);
|
|
||||||
titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
|
|
||||||
mainPanel.add(titleLabel, BorderLayout.NORTH);
|
|
||||||
|
|
||||||
// 表单面板
|
|
||||||
JPanel formPanel = new JPanel(new GridLayout(3, 2, 10, 10));
|
|
||||||
|
|
||||||
formPanel.add(new JLabel("用户名:"));
|
|
||||||
idField = new JTextField();
|
|
||||||
formPanel.add(idField);
|
|
||||||
|
|
||||||
formPanel.add(new JLabel("密码:"));
|
|
||||||
passwordField = new JPasswordField();
|
|
||||||
formPanel.add(passwordField);
|
|
||||||
|
|
||||||
// 按钮面板
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout());
|
|
||||||
JButton loginButton = new JButton("登录");
|
|
||||||
JButton registerButton = new JButton("注册账号");
|
|
||||||
JButton exitButton = new JButton("退出");
|
|
||||||
|
|
||||||
buttonPanel.add(loginButton);
|
|
||||||
buttonPanel.add(registerButton);
|
|
||||||
buttonPanel.add(exitButton);
|
|
||||||
|
|
||||||
formPanel.add(buttonPanel);
|
|
||||||
|
|
||||||
mainPanel.add(formPanel, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
// 添加事件监听器
|
|
||||||
loginButton.addActionListener(new LoginListener());
|
|
||||||
registerButton.addActionListener(e -> openRegisterFrame());
|
|
||||||
exitButton.addActionListener(e -> System.exit(0));
|
|
||||||
|
|
||||||
add(mainPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LoginListener implements ActionListener {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
String id = idField.getText().trim();
|
|
||||||
String password = new String(passwordField.getPassword());
|
|
||||||
|
|
||||||
if (id.isEmpty() || password.isEmpty()) {
|
|
||||||
JOptionPane.showMessageDialog(Login_frame.this,
|
|
||||||
"请输入用户名和密码", "错误", JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String result = userService.login(id, password);
|
|
||||||
if (result.equals("登陆成功")) {
|
|
||||||
JOptionPane.showMessageDialog(Login_frame.this,
|
|
||||||
"登录成功!", "成功", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
openMainFrame(userService.find_user_i(id).get_email());
|
|
||||||
} else {
|
|
||||||
JOptionPane.showMessageDialog(Login_frame.this,
|
|
||||||
result, "登录失败", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openRegisterFrame() {
|
|
||||||
Register_frame registerFrame = new Register_frame(userService);
|
|
||||||
registerFrame.setVisible(true);
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openMainFrame(String email) {
|
|
||||||
Main_frame mainFrame = new Main_frame(userService, email);
|
|
||||||
mainFrame.setVisible(true);
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,156 +0,0 @@
|
|||||||
package View;
|
|
||||||
|
|
||||||
import Service.Exam_service;
|
|
||||||
import Service.User_service;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
public class Main_frame extends JFrame {
|
|
||||||
private User_service userService;
|
|
||||||
private String email;
|
|
||||||
private JComboBox<String> typeComboBox;
|
|
||||||
private JTextField countField;
|
|
||||||
|
|
||||||
public Main_frame(User_service userService, String email) {
|
|
||||||
this.userService = userService;
|
|
||||||
this.email = email;
|
|
||||||
initializeUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeUI() {
|
|
||||||
setTitle("主界面");
|
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
setSize(500, 400);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
setResizable(false);
|
|
||||||
|
|
||||||
// 主面板
|
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
|
|
||||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
|
||||||
|
|
||||||
// 标题
|
|
||||||
JLabel titleLabel = new JLabel("数学学习软件", JLabel.CENTER);
|
|
||||||
titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
|
|
||||||
mainPanel.add(titleLabel, BorderLayout.NORTH);
|
|
||||||
|
|
||||||
// 设置面板
|
|
||||||
JPanel settingPanel = new JPanel(new GridLayout(2, 2, 10, 10));
|
|
||||||
|
|
||||||
settingPanel.add(new JLabel("选择难度:"));
|
|
||||||
typeComboBox = new JComboBox<>(new String[]{"小学", "初中", "高中"});
|
|
||||||
settingPanel.add(typeComboBox);
|
|
||||||
|
|
||||||
settingPanel.add(new JLabel("题目数量:"));
|
|
||||||
countField = new JTextField("10");
|
|
||||||
settingPanel.add(countField);
|
|
||||||
|
|
||||||
mainPanel.add(settingPanel, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
// 按钮面板
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 10));
|
|
||||||
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
|
|
||||||
JButton startButton = new JButton("开始做题");
|
|
||||||
JButton changePasswordButton = new JButton("修改密码");
|
|
||||||
JButton logoutButton = new JButton("退出登录");
|
|
||||||
JButton UnregisterButton = new JButton("删除账号");
|
|
||||||
|
|
||||||
buttonPanel.add(startButton);
|
|
||||||
buttonPanel.add(changePasswordButton);
|
|
||||||
buttonPanel.add(logoutButton);
|
|
||||||
buttonPanel.add(UnregisterButton);
|
|
||||||
|
|
||||||
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
|
||||||
|
|
||||||
// 添加事件监听器
|
|
||||||
startButton.addActionListener(new StartListener());
|
|
||||||
changePasswordButton.addActionListener(e -> openChangePasswordFrame());
|
|
||||||
logoutButton.addActionListener(e -> openLoginFrame());
|
|
||||||
UnregisterButton.addActionListener(e-> UnregisterOperation());
|
|
||||||
|
|
||||||
add(mainPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class StartListener implements ActionListener {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
String type = (String) typeComboBox.getSelectedItem();
|
|
||||||
String countText = countField.getText().trim();
|
|
||||||
|
|
||||||
if (countText.isEmpty()) {
|
|
||||||
JOptionPane.showMessageDialog(Main_frame.this,
|
|
||||||
"请输入题目数量", "错误", JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int count;
|
|
||||||
try {
|
|
||||||
count = Integer.parseInt(countText);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
JOptionPane.showMessageDialog(Main_frame.this,
|
|
||||||
"题目数量必须是数字", "错误", JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count < 10 || count > 30) {
|
|
||||||
JOptionPane.showMessageDialog(Main_frame.this,
|
|
||||||
"题目数量必须在10-30之间", "错误", JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建考试服务
|
|
||||||
Exam_service examService = new Exam_service(count, type, userService.find_user(email).get_id());
|
|
||||||
openExamFrame(examService);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openExamFrame(Exam_service examService) {
|
|
||||||
Exam_frame examFrame = new Exam_frame(examService, userService, email);
|
|
||||||
examFrame.setVisible(true);
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openChangePasswordFrame() {
|
|
||||||
JPasswordField oldPasswordField = new JPasswordField();
|
|
||||||
JPasswordField newPasswordField = new JPasswordField();
|
|
||||||
JPasswordField confirmPasswordField = new JPasswordField();
|
|
||||||
|
|
||||||
JPanel panel = new JPanel(new GridLayout(3, 2));
|
|
||||||
panel.add(new JLabel("原密码:"));
|
|
||||||
panel.add(oldPasswordField);
|
|
||||||
panel.add(new JLabel("新密码:"));
|
|
||||||
panel.add(newPasswordField);
|
|
||||||
panel.add(new JLabel("确认新密码:"));
|
|
||||||
panel.add(confirmPasswordField);
|
|
||||||
|
|
||||||
int result = JOptionPane.showConfirmDialog(this, panel, "修改密码", JOptionPane.OK_CANCEL_OPTION);
|
|
||||||
if (result == JOptionPane.OK_OPTION) {
|
|
||||||
String oldPassword = new String(oldPasswordField.getPassword());
|
|
||||||
String newPassword = new String(newPasswordField.getPassword());
|
|
||||||
String confirmPassword = new String(confirmPasswordField.getPassword());
|
|
||||||
|
|
||||||
if (!newPassword.equals(confirmPassword)) {
|
|
||||||
JOptionPane.showMessageDialog(this,
|
|
||||||
"两次输入的新密码不一致", "错误", JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String changeResult = userService.change_pwd(email, oldPassword, newPassword);
|
|
||||||
JOptionPane.showMessageDialog(this, changeResult, "修改密码", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openLoginFrame() {
|
|
||||||
Login_frame loginFrame = new Login_frame(userService);
|
|
||||||
loginFrame.setVisible(true);
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UnregisterOperation(){
|
|
||||||
String result=userService.Unregister(email);
|
|
||||||
JOptionPane.showMessageDialog(this, result, "删除账号", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
openLoginFrame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,82 +0,0 @@
|
|||||||
package View;
|
|
||||||
|
|
||||||
import Base.Exam_result;
|
|
||||||
import Service.Exam_service;
|
|
||||||
import Service.User_service;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class Result_frame extends JFrame {
|
|
||||||
private Exam_service examService;
|
|
||||||
private Exam_result result;
|
|
||||||
private User_service userService;
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
public Result_frame(Exam_service ex,Exam_result result, User_service userService, String email) {
|
|
||||||
this.examService=ex;
|
|
||||||
this.result = result;
|
|
||||||
this.userService = userService;
|
|
||||||
this.email = email;
|
|
||||||
initializeUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeUI() {
|
|
||||||
setTitle("考试结果");
|
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
setSize(500, 400);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
setResizable(false);
|
|
||||||
|
|
||||||
// 主面板
|
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
|
|
||||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
|
||||||
|
|
||||||
// 标题
|
|
||||||
JLabel titleLabel = new JLabel("考试结果", JLabel.CENTER);
|
|
||||||
titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
|
|
||||||
mainPanel.add(titleLabel, BorderLayout.NORTH);
|
|
||||||
|
|
||||||
// 结果信息
|
|
||||||
JPanel resultPanel = new JPanel(new GridLayout(5, 1, 10, 10));
|
|
||||||
resultPanel.add(new JLabel("考试类型: " + result.getExamType()));
|
|
||||||
resultPanel.add(new JLabel("题目数量: " + result.getTotalQuestions()));
|
|
||||||
resultPanel.add(new JLabel("正确题目: " + result.getCorrectAnswers()));
|
|
||||||
resultPanel.add(new JLabel("得分: " + String.format("%.2f", result.getScore())));
|
|
||||||
resultPanel.add(new JLabel("用时: " + result.getDuration()));
|
|
||||||
|
|
||||||
mainPanel.add(resultPanel, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
// 按钮面板
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout());
|
|
||||||
JButton reviewButton =new JButton("查看错题");
|
|
||||||
JButton mainMenuButton = new JButton("返回主菜单");
|
|
||||||
JButton exitButton = new JButton("退出");
|
|
||||||
|
|
||||||
buttonPanel.add(reviewButton);
|
|
||||||
buttonPanel.add(mainMenuButton);
|
|
||||||
buttonPanel.add(exitButton);
|
|
||||||
|
|
||||||
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
|
||||||
|
|
||||||
// 添加事件监听器
|
|
||||||
reviewButton.addActionListener(e->openReviewFrame());
|
|
||||||
mainMenuButton.addActionListener(e -> openMainFrame());
|
|
||||||
exitButton.addActionListener(e -> System.exit(0));
|
|
||||||
|
|
||||||
add(mainPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openMainFrame() {
|
|
||||||
Main_frame mainFrame = new Main_frame(userService, email);
|
|
||||||
mainFrame.setVisible(true);
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openReviewFrame(){
|
|
||||||
examService.set_now_index(0);
|
|
||||||
Review_frame reviewFrame= new Review_frame(examService,userService, email,result);
|
|
||||||
reviewFrame.setVisible(true);
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue