⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 administerframe.java

📁 学生考试系统 有学生和老师登录。 学生登录可以选择不同的题库进行考试或练习
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.svse.view;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JComboBox;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Toolkit;
import java.awt.Dimension;
import javax.swing.ButtonGroup;
import com.svse.dao.QuestionDao;
import com.svse.bean.QuestionBean;
import javax.swing.JOptionPane;
import java.util.ArrayList;

public class AdministerFrame extends JFrame {
    LoginFrame Login;
    public AdministerFrame() {
        try {
            jbInit();
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            //设置窗体大小
            this.setSize(420, 480);
            //让窗体居中
            // Center the window
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Dimension frameSize = this.getSize();
            if (frameSize.height > screenSize.height) {
                frameSize.height = screenSize.height;
            }
            if (frameSize.width > screenSize.width) {
                frameSize.width = screenSize.width;
            }
            this.setLocation((screenSize.width - frameSize.width) / 2,
                             (screenSize.height - frameSize.height) / 2);

            //设置可见度
            this.setVisible(true);
            this.cbo_subject.addItem("");
            this.cbo_subject.addItem("JAVA");
            this.cbo_subject.addItem("HTML");
            this.cbo_subject.addItem("JavaScript");
            this.cbo_subject.addItem("SQLServer2005");
            this.cbo_subject.addItem("J2SE");

        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public AdministerFrame(LoginFrame LoginFrame) {
        this();
        this.Login = LoginFrame;
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        lbl_title.setText("题 干:");
        lbl_title.setBounds(new Rectangle(60, 98, 42, 21));
        btn_update.setBounds(new Rectangle(48, 387, 100, 25));
        btn_update.setText("修改此题");
        btn_update.addActionListener(new
                                     AdministerFrame_btn_update_actionAdapter(this));
        btn_insert.setBounds(new Rectangle(48, 342, 100, 25));
        btn_insert.setText("添加此题");
        btn_insert.addActionListener(new
                                     AdministerFrame_btn_insert_actionAdapter(this));
        btn_delete.setBounds(new Rectangle(153, 342, 100, 25));
        btn_delete.setText("删除此题");
        btn_delete.addActionListener(new
                                     AdministerFrame_btn_delete_actionAdapter(this));
        btn_clearl.setBounds(new Rectangle(153, 387, 100, 25));
        btn_clearl.setText("清空文本");
        btn_clearl.addActionListener(new
                                     AdministerFrame_btn_clearl_actionAdapter(this));
        txt_answer.setBounds(new Rectangle(115, 277, 49, 21));
        lbl_answer.setText("答 案:");
        lbl_answer.setBounds(new Rectangle(60, 280, 42, 15));
        lbl_subject.setText("科 目:");
        lbl_subject.setBounds(new Rectangle(59, 311, 42, 15));
        cbo_subject.setBounds(new Rectangle(115, 307, 104, 23));
        txt_optionC.setBounds(new Rectangle(115, 211, 192, 21));
        btn_back.setBounds(new Rectangle(262, 365, 100, 25));
        btn_back.setText("返回登陆");
        btn_back.addActionListener(new AdministerFrame_btn_back_actionAdapter(this));
        txt_optionA.setBounds(new Rectangle(115, 151, 192, 21));
        lbl_topTitle.setFont(new java.awt.Font("宋体", Font.BOLD, 16));
        lbl_topTitle.setText("欢迎使用考试题库系统");
        lbl_topTitle.setBounds(new Rectangle(120, 6, 170, 27));
        txt_optionB.setBounds(new Rectangle(115, 180, 192, 21));
        txt_title.setLineWrap(true);
        txt_title.setBounds(new Rectangle(115, 76, 192, 65));
        txt_optionD.setBounds(new Rectangle(115, 242, 192, 21));
        lbl_subjectID.setText("题 号:");
        lbl_subjectID.setBounds(new Rectangle(60, 42, 42, 21));
        txt_questionID.setBounds(new Rectangle(113, 41, 72, 21));
        btn_select.setBounds(new Rectangle(207, 39, 100, 25));
        btn_select.setText("查找题目");
        btn_select.addActionListener(new
                                     AdministerFrame_btn_select_actionAdapter(this));
        lbl_optionA.setText("选项A:");
        lbl_optionA.setBounds(new Rectangle(60, 151, 51, 21));
        lbl_optionB.setText("选项B:");
        lbl_optionB.setBounds(new Rectangle(60, 180, 55, 21));
        lbl_optionD.setText("选项D:");
        lbl_optionD.setBounds(new Rectangle(60, 242, 54, 21));
        lbl_optionC.setText("选项C:");
        lbl_optionC.setBounds(new Rectangle(60, 211, 53, 21));
        this.getContentPane().add(lbl_topTitle);
        this.getContentPane().add(txt_optionB);
        this.getContentPane().add(txt_optionC);
        this.getContentPane().add(txt_optionD);
        this.getContentPane().add(cbo_subject);
        this.getContentPane().add(txt_answer);
        this.getContentPane().add(txt_title);
        this.getContentPane().add(txt_optionA);
        this.getContentPane().add(txt_questionID);
        this.getContentPane().add(lbl_optionA);
        this.getContentPane().add(lbl_optionB);
        this.getContentPane().add(lbl_optionD);
        this.getContentPane().add(lbl_optionC);
        this.getContentPane().add(lbl_answer);
        this.getContentPane().add(lbl_subject);
        this.getContentPane().add(lbl_title);
        this.getContentPane().add(lbl_subjectID);
        this.getContentPane().add(btn_update);
        this.getContentPane().add(btn_delete);
        this.getContentPane().add(btn_insert);
        this.getContentPane().add(btn_clearl);
        this.getContentPane().add(btn_back);
        this.getContentPane().add(btn_select);
    }

    JLabel lbl_title = new JLabel();
    JTextField txt_optionD = new JTextField();
    JTextArea txt_title = new JTextArea();
    JTextField txt_optionB = new JTextField();
    JLabel lbl_topTitle = new JLabel();
    JTextField txt_optionA = new JTextField();
    JButton btn_back = new JButton();
    JTextField txt_optionC = new JTextField();
    JButton btn_update = new JButton();
    JButton btn_insert = new JButton();
    JButton btn_delete = new JButton();
    JButton btn_clearl = new JButton();
    JTextField txt_answer = new JTextField();
    JLabel lbl_answer = new JLabel();
    JLabel lbl_subject = new JLabel();
    JComboBox cbo_subject = new JComboBox();
    JLabel lbl_subjectID = new JLabel();
    JTextField txt_questionID = new JTextField();
    JButton btn_select = new JButton();
    ButtonGroup buttonGroup1 = new ButtonGroup();
    JLabel lbl_optionA = new JLabel();
    JLabel lbl_optionB = new JLabel();
    JLabel lbl_optionD = new JLabel();
    JLabel lbl_optionC = new JLabel();


    String strQuestionID;
    int questionID;
    QuestionDao dao = new QuestionDao();
    QuestionBean bean;
    ArrayList<QuestionBean> list = dao.getAll(questionID);
    //查找
    public void btn_select_actionPerformed(ActionEvent e) {
        //判断用户输入的题号是否存在
        strQuestionID = this.txt_questionID.getText();
        if (strQuestionID.equals("")) {
            JOptionPane.showMessageDialog(this, "请输入题号!");
            return;
        }

        questionID = Integer.parseInt(strQuestionID);

        if (dao.getOne(questionID) == null) {
            btn_clearl_actionPerformed(null);
            JOptionPane.showMessageDialog(this, "对不起没有你要找的题目!");
            return;
        }

        bean = dao.getOne(questionID);
        this.txt_title.setText(bean.getTitle());
        this.txt_optionA.setText(bean.getOptionA());
        this.txt_optionB.setText(bean.getOptionB());
        this.txt_optionC.setText(bean.getOptionC());
        this.txt_optionD.setText(bean.getOptionD());
        this.txt_answer.setText(bean.getAnswer());

    }

    //前台验证方法
    private boolean checkInfo() {
        return title.isEmpty() || optionA.isEmpty() || optionB.isEmpty() ||
                optionC.isEmpty() ||
                optionD.isEmpty() || answer.isEmpty() ||
                strCourseID.isEmpty();

    }


    //清空
    public void btn_clearl_actionPerformed(ActionEvent e) {
        this.txt_answer.setText("");
        this.txt_optionA.setText("");
        this.txt_optionB.setText("");
        this.txt_optionC.setText("");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -