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

📄 classframsourse.java

📁 实现了一个小型的成绩管理系统。希望能帮助大家。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package Course;

import java.awt.*;

import javax.swing.*;
import java.awt.Dimension;
import java.awt.BorderLayout;
import javax.swing.table.DefaultTableModel;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ClassFramSourse extends JFrame implements ActionListener{

    private CourseSys CourseSys1;
    Save_Load data=new Save_Load();

    JPanel contentPane;
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel ClassInput = new JPanel();
    JPanel studentInput = new JPanel();
    JPanel scoreIn = new JPanel();
    JPanel search = new JPanel();

    JScrollPane jScrollPane1 = new JScrollPane();
    final Object[] columnNames = {"年级","专业", "班别","学生人数"};
    Object[][] rowData = {};
    DefaultTableModel model = new DefaultTableModel(rowData,columnNames){public boolean isCellEditable(int row, int column) {return false;}};

    JTable jTable1 = new JTable(model);
    JLabel jLabel1 = new JLabel();
    JTextField ClassInText1 = new JTextField();
    JLabel jLabel2 = new JLabel();
    JTextField ClassInText2 = new JTextField();
    JLabel jLabel3 = new JLabel();
    JTextField ClassInText3 = new JTextField();
    JLabel jLabel4 = new JLabel();
    JTextField ClassInText4 = new JTextField();
    JButton ClassInOK = new JButton();
    JButton jButton3 = new JButton();
    JButton SaveOK = new JButton();
    JLabel jLabel5 = new JLabel();
    JComboBox StuInBox = new JComboBox();
    JButton StuInOk = new JButton();
    JButton ScoreInOK = new JButton();
    JLabel jLabel6 = new JLabel();
    JComboBox ScoreInBox1 = new JComboBox();
    JComboBox SearchBox1 = new JComboBox();
    JLabel jLabel7 = new JLabel();
    JTabbedPane jTabbedPane2 = new JTabbedPane();
    JPanel jPanel1 = new JPanel();
    JPanel NumModel = new JPanel();
    JPanel jPanel3 = new JPanel();
    JPanel LineModel = new JPanel();
    JPanel CircleModel = new JPanel();
    JComboBox SearchBox2 = new JComboBox();
    JLabel 科目 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JComboBox ScoreInBox2 = new JComboBox();
    JLabel jLabel9 = new JLabel();
    //
    JScrollPane jScrollPane2 = new JScrollPane();
    final Object[] columnNames1 = {"学号","姓名"};

    DefaultTableModel model1 = new DefaultTableModel(rowData,columnNames1);

    JTable jTable2 = new JTable(model1);
    //

    final Object[] columnNames2= {"学号","姓名", "分数"};
    DefaultTableModel model2 = new DefaultTableModel(rowData,columnNames2){public boolean isCellEditable(int row, int column) {if(column==2)return true;else return false;}};
    JScrollPane jScrollPane3 = new JScrollPane();
    JTable jTable3 = new JTable(model2);


    final Object[] columnNames3= {"基本信息","信息设置"};
    Object[][] rowData3= {{"课程编号",null},{"课程名称",null},{"课程学分",null},{"课程学时",null},{"考试时间",null},{"选课人数",null}};
    DefaultTableModel model3 = new DefaultTableModel(rowData3,columnNames3){public boolean isCellEditable(int row, int column) {if(column==1)return true;else return false;}};
    JScrollPane jScrollPane4 = new JScrollPane();
    JTable jTable4 = new JTable(model3); //

    JPanel jPanel2 = new JPanel();
    JButton ClassDel = new JButton();
    JButton CourseDel = new JButton();
    public ClassFramSourse() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(null);
        setSize(new Dimension(476, 465));
        setTitle("Frame Title");
        ClassInput.setLayout(null);
        jScrollPane1.setBounds(new Rectangle(16, 6, 414, 190));
        jTabbedPane1.setBounds(new Rectangle(5, 13, 455, 419));
        jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jLabel1.setText("年级");
        jLabel1.setBounds(new Rectangle(27, 222, 101, 26));
        ClassInText1.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        ClassInText1.setBounds(new Rectangle(108, 224, 103, 23));
        jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jLabel2.setText("专业");
        jLabel2.setBounds(new Rectangle(27, 256, 67, 28));
        ClassInText2.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        ClassInText2.setDisabledTextColor(Color.black);
        ClassInText2.setBounds(new Rectangle(107, 262, 104, 21));
        jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jLabel3.setText("班级");
        jLabel3.setBounds(new Rectangle(27, 288, 61, 29));
        ClassInText3.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        ClassInText3.setBounds(new Rectangle(107, 291, 104, 22));
        jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        jLabel4.setText("人数");
        jLabel4.setBounds(new Rectangle(27, 317, 62, 25));
        ClassInText4.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
        ClassInText4.setBounds(new Rectangle(107, 320, 104, 22));
        ClassInOK.setBounds(new Rectangle(319, 252, 81, 23));
        ClassInOK.setText("OK");
        jButton3.setBounds(new Rectangle(0, 0, 81, 23));
        jButton3.setText("jButton3");
        SaveOK.setBounds(new Rectangle(289, 12, 81, 23));
        SaveOK.setText("保存");
        studentInput.setLayout(null);
        scoreIn.setLayout(null);
        search.setLayout(null);
        jLabel5.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
        jLabel5.setText("选择班级");
        jLabel5.setBounds(new Rectangle(9, 18, 123, 26));
        StuInBox.setBounds(new Rectangle(9, 53, 181, 21));
        StuInBox.addItem(null);
        StuInOk.setBounds(new Rectangle(9, 109, 81, 23));
        StuInOk.setText("OK");
        ScoreInOK.setBounds(new Rectangle(7, 294, 81, 23));
        ScoreInOK.setText("确定");
        jLabel6.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
        jLabel6.setText("选择班级");
        jLabel6.setBounds(new Rectangle(7, 11, 153, 26));
        ScoreInBox1.setBounds(new Rectangle(7, 44, 149, 24));
        ScoreInBox1.addItem(null);
        ScoreInBox2.addItem(null);
        ScoreInBox2.addItem("新增课程");
        SearchBox1.setBounds(new Rectangle(85, 4, 333, 23));
        SearchBox1.addItem(null);
        jLabel7.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
        jLabel7.setText("选择班级");
        jLabel7.setBounds(new Rectangle(2, 2, 138, 25));
        jTabbedPane2.setBounds(new Rectangle(0, 62, 450, 328));
        jPanel1.setBounds(new Rectangle(0, 0, 10, 10));
        jPanel3.setBounds(new Rectangle(0, 0, 10, 10));
        SearchBox2.setBounds(new Rectangle(85, 32, 167, 23));
        SearchBox2.addItem(null);
        科目.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
        科目.setText("科目");
        科目.setBounds(new Rectangle(42, 34, 62, 18));
        jLabel8.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
        jLabel8.setText("课程选择");
        jLabel8.setBounds(new Rectangle(7, 74, 86, 24));
        ScoreInBox2.setBounds(new Rectangle(7, 101, 146, 21));
        jLabel9.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
        jLabel9.setText("课程信息");
        jLabel9.setBounds(new Rectangle(6, 125, 85, 26));
        jScrollPane2.setBounds(new Rectangle(196, 0, 257, 390));
        jScrollPane3.setBounds(new Rectangle(157, 0, 293, 390));
        jScrollPane4.setBounds(new Rectangle(5, 150, 150, 121));
        NumModel.setLayout(null);
        jPanel2.setBounds(new Rectangle(0, 0, 10, 10));
        LineModel.setLayout(null);
        CircleModel.setLayout(null);
        ClassDel.setBounds(new Rectangle(9, 156, 81, 23));
        ClassDel.setActionCommand("Delete");
        ClassDel.setText("Delete");
        CourseDel.setBounds(new Rectangle(7, 347, 81, 23));
        CourseDel.setActionCommand("Delete");
        CourseDel.setText("Delete");
        ClassInput.add(jLabel1);
        ClassInput.add(ClassInText1);
        ClassInput.add(jLabel2);
        ClassInput.add(ClassInText2);
        ClassInput.add(jLabel3);
        ClassInput.add(jLabel4);
        ClassInput.add(ClassInText3);
        ClassInput.add(ClassInText4);
        ClassInput.add(ClassInOK);
        ClassInput.add(jScrollPane1);
        studentInput.add(jLabel5);
        studentInput.add(StuInBox);
        studentInput.add(StuInOk);
        studentInput.add(jScrollPane2);
        studentInput.add(ClassDel);
        jScrollPane2.getViewport().add(jTable2);
        scoreIn.add(jLabel6);
        scoreIn.add(ScoreInBox1);
        scoreIn.add(jLabel8);
        scoreIn.add(ScoreInBox2);
        scoreIn.add(jLabel9);
        scoreIn.add(jScrollPane3);
        scoreIn.add(jScrollPane4);
        scoreIn.add(ScoreInOK);
        scoreIn.add(CourseDel);

        jScrollPane4.getViewport().add(jTable4);
        jScrollPane3.getViewport().add(jTable3);

        search.add(jTabbedPane2);
        jScrollPane1.getViewport().add(jTable1);


        contentPane.add(SaveOK);
        contentPane.add(jTabbedPane1, null);
        jTabbedPane2.add(NumModel, "成绩数字模式");
        jTabbedPane2.add(LineModel, "条形模式");
        jTabbedPane2.add(CircleModel, "饼图模式");
        search.add(jLabel7);
        search.add(SearchBox1);
        search.add(SearchBox2);
        search.add(科目);
        jTabbedPane1.add(ClassInput, "班级录入");
        jTabbedPane1.add(studentInput, "学生录入");
        jTabbedPane1.add(scoreIn, "成绩录入"); //个人数据初始话
        jTabbedPane1.add(search, "成绩查询");
        this.CourseSys1=data.Load();
        if(CourseSys1!=null)
        {
            //
            for (int i = 0; i < this.CourseSys1.getClassNum(); i++) {
                String[] add = this.CourseSys1.getMyClass()[i].getClassMes();
                model.addRow(add);
                StuInBox.addItem(this.CourseSys1.getMyClass()[i].toString());
                ScoreInBox1.addItem(this.CourseSys1.getMyClass()[i].toString());
                SearchBox1.addItem(this.CourseSys1.getMyClass()[i].toString());
            }
            //

        }
        else CourseSys1=new CourseSys();

        this.ClassInOK.addActionListener(this);
        this.SaveOK.addActionListener(this);
        this.StuInBox.addActionListener(this);
        this.ScoreInBox1.addActionListener(this);
        this.ScoreInBox2.addActionListener(this);
        this.SearchBox1.addActionListener(this);
        this.SearchBox2.addActionListener(this);
        this.StuInOk.addActionListener(this);
        this.ScoreInBox1.addActionListener(this);
        this.ScoreInBox2.addActionListener(this);
        this.ScoreInOK.addActionListener(this);
        this.ClassDel.addActionListener(this);
        this.CourseDel.addActionListener(this);

    }
   //事件跟踪驱动
    public void actionPerformed(ActionEvent e){
        //增加班级
        if(e.getSource()==this.ClassInOK)
        {
            String b=this.ClassInText1.getText()+"年级"+this.ClassInText2.getText()+this.ClassInText3.getText()+"班";
            try
            {
                if (CourseSys1.findClass(b) == null) {
                    this.CourseSys1.addClass(this.ClassInText1.getText(),
                                             this.ClassInText2.getText(),
                                             this.ClassInText3.getText(),
                                             this.ClassInText4.getText());
                    String[] a = {this.ClassInText1.getText(),
                                 this.ClassInText2.getText(),
                                 this.ClassInText3.getText(),
                                 this.ClassInText4.getText()};
                    model.addRow(a);
                    StuInBox.addItem(b);
                    ScoreInBox1.addItem(b);
                    SearchBox1.addItem(b);
                } else
                    JOptionPane.showMessageDialog(null, "有这个班级了", "课程设计提示",JOptionPane.INFORMATION_MESSAGE);
            }
            catch(Exception var3)
            {
                JOptionPane.showMessageDialog(null, "信息不足", "课程设计提示",JOptionPane.INFORMATION_MESSAGE);
            }
        }
        //存储
        else if(e.getSource()==this.SaveOK)
        {
            try
            {
                this.data.Save(this.CourseSys1);

⌨️ 快捷键说明

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