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

📄 addscoremenujpanel.java

📁 用Java做的一个学生考试分析程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(21, 21, 21)
                        .add(jLabel1)
                        .add(17, 17, 17)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel2)
                            .add(grade, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(14, 14, 14)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel3)
                            .add(major, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel8)
                            .add(studentId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(layout.createSequentialGroup()
                        .add(37, 37, 37)
                        .add(text, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(19, 19, 19)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(classNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel9)
                    .add(score, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(20, 20, 20)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(attendNumber, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel5)
                    .add(input))
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(13, 13, 13)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel6)
                            .add(courseId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(layout.createSequentialGroup()
                        .add(56, 56, 56)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel14)
                            .add(minute, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel13)
                            .add(hour, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel12)
                            .add(date, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel11)
                            .add(month, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel10)
                            .add(jLabel7)
                            .add(year, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .add(19, 19, 19)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(confirm)
                    .add(cancel))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void inputButtonActionListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inputButtonActionListener
        long id;
        float score;
        try{
            id=Long.parseLong(this.studentId.getText());
            score=Float.parseFloat(this.score.getText());
            if((score<0)||(score>ScoreMenu.MAX_SCORE)){
                JOptionPane.showMessageDialog(null,"分数超出范围","出错",JOptionPane.ERROR_MESSAGE);
                return;
            }
            int num=scoreMenu.getNumberOfAttendTestStudent();
            if(!scoreMenu.setScoreOfTest(score,id)){
                JOptionPane.showMessageDialog(null,"输入的学生不属于此班级","出错",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if(scoreMenu.getNumberOfAttendTestStudent()==num){
                JOptionPane.showMessageDialog(null,"已经修改了学号为"+id+"的学生的成绩","修改",JOptionPane.WARNING_MESSAGE);
                return;
            }
            JOptionPane.showMessageDialog(null,"已经记录了第"+(num+1)+"个学生的成绩","登记",JOptionPane.WARNING_MESSAGE);
            if(attendTestNumber<=scoreMenu.getNumberOfAttendTestStudent()){
                JOptionPane.showMessageDialog(null,"已经成功完成了此次成绩的登记工作","登记成绩单成功",JOptionPane.WARNING_MESSAGE);
                reset();
                this.scoreMenu.saveToFile();
                return;
            }
            this.text.setText("输入第"+(num+2)+"个学生的信息");
        }catch(Exception e){
            JOptionPane.showMessageDialog(null,"输入的数据格式有误","出错",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_inputButtonActionListener
    private void reset(){
        this.grade.setEditable(true);
        this.major.setEditable(true);
        this.classNumber.setEditable(true);
        this.attendNumber.setEditable(true);
        this.courseId.setEditable(true);
        this.confirm.setEnabled(true);
        this.year.setEditable(true);
        this.month.setEditable(true);
        this.date.setEditable(true);
        this.hour.setEditable(true);
        this.minute.setEditable(true);
        this.text.setText("");
        this.studentId.setEditable(false);
        this.studentId.setText("");
        this.score.setEditable(false);
        this.score.setText("");
        this.input.setEnabled(false);
    }
    private void cancelButtonActionListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionListener
        int select=JOptionPane.showConfirmDialog(null,"确认取消本次输入的成绩单","确认",JOptionPane.OK_CANCEL_OPTION);
        if(select==0)
            reset();
    }//GEN-LAST:event_cancelButtonActionListener

    private void confirmButtonActionListener(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmButtonActionListener
        String major,courseId;
        int grade,classNumber;
        int []testTime=new int[5];
        try{
            grade=Integer.parseInt(this.grade.getText());
            major=this.major.getText();
            courseId=this.courseId.getText();
            classNumber=Integer.parseInt(this.classNumber.getText());
            attendTestNumber=Integer.parseInt(this.attendNumber.getText());
            testTime[0]=Integer.parseInt(this.year.getText());
            testTime[1]=Integer.parseInt(this.month.getText());
            testTime[2]=Integer.parseInt(this.date.getText());
            testTime[3]=Integer.parseInt(this.hour.getText());
            testTime[4]=Integer.parseInt(this.minute.getText());
            if((testTime[1]>12)||(testTime[1]<=0)||(testTime[2]>31)||(testTime[2]<=0)||
                    (testTime[3]>24)||(testTime[3]<0)||(testTime[4]>60)||(testTime[4]<0)){
                JOptionPane.showMessageDialog(null,"考试日期格式有误","出错",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if(attendTestNumber<=0){
                JOptionPane.showMessageDialog(null,"参加考试人数不能少于1","出错",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if((tempCourse=Course.queryFromFile(courseId))==null){
                JOptionPane.showMessageDialog(null,"课程文件中没有此编号的课程信息记录","出错",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if((tempClass=Class.queryFromFile(grade,major,classNumber))==null){
                JOptionPane.showMessageDialog(null,"班级文件中没有此班级信息的记录","出错",JOptionPane.ERROR_MESSAGE);
                return;
            }
            else if(tempClass.getStudentNumber()<this.attendTestNumber){
                JOptionPane.showMessageDialog(null,"参加考试人数多于班级人数","出错",JOptionPane.ERROR_MESSAGE);
                return;
            }
            if((scoreMenu=ScoreMenu.queryFromFile(tempClass,tempCourse))!=null){
                JOptionPane.showMessageDialog(null,"系统中已经存在该班级该门课程的成绩单","出错",JOptionPane.ERROR_MESSAGE);
                return;
            }
            scoreMenu=new ScoreMenu(tempClass,tempCourse,testTime,0,null,null);
            this.grade.setEditable(false);
            this.major.setEditable(false);
            this.classNumber.setEditable(false);
            this.courseId.setEditable(false);
            this.attendNumber.setEditable(false);
            this.confirm.setEnabled(false);
            this.text.setText("输入第1个学生信息:");
            this.studentId.setEditable(true);
            this.score.setEditable(true);
            this.input.setEnabled(true);
            this.year.setEditable(false);
            this.month.setEditable(false);
            this.date.setEditable(false);
            this.hour.setEditable(false);
            this.minute.setEditable(false);
        }catch(Exception e){
            JOptionPane.showMessageDialog(null,"输入数据格式有误","出错",JOptionPane.ERROR_MESSAGE);            
        }
    }//GEN-LAST:event_confirmButtonActionListener
    private ScoreMenu scoreMenu;
    private Class tempClass;
    private Course tempCourse;
    private int attendTestNumber;
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JTextField attendNumber;
    private javax.swing.JButton cancel;
    private javax.swing.JTextField classNumber;
    private javax.swing.JButton confirm;
    private javax.swing.JTextField courseId;
    private javax.swing.JTextField date;
    private javax.swing.JTextField grade;
    private javax.swing.JTextField hour;
    private javax.swing.JButton input;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField major;
    private javax.swing.JTextField minute;
    private javax.swing.JTextField month;
    private javax.swing.JTextField score;
    private javax.swing.JTextField studentId;
    private javax.swing.JLabel text;
    private javax.swing.JTextField year;
    // 变量声明结束//GEN-END:variables
    
}

⌨️ 快捷键说明

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