java实现学生成绩信息管理系统
JAVA大作业:学生成绩管理系统(含有用户界面),供大家参考,具体内容如下
ps:多个包写在一起
packagetest; importjava.awt.*; importjava.awt.event.*; importjavax.swing.*; importjava.util.ArrayList; classperson{ publicStringname; publicStringage; } classStudentextendsperson{ publicStringno; publicStringscore1,score2,score3,score4; publicStudent(Stringno,Stringname,Stringage,Stringscore1,Stringscore2,Stringscore3,Stringscore4){ this.no=no; this.name=name; this.age=age; this.score1=score1; this.score2=score2; this.score3=score3; this.score4=score4; } publicStringgetNo(){ returnthis.no; } publicvoidsetNo(Stringno){ this.no=no; } publicStringgetName(){ returnthis.name; } publicvoidsetName(Stringname){ this.name=name; } publicStringgetAge(){ returnthis.age; } publicvoidsetAge(Stringage){ this.age=age; } publicStringgetscore1(){ returnthis.score1; } publicvoidsetscore1(Stringscore1){ this.score1=score1; } publicStringgetscore2(){ returnthis.score2; } publicvoidsetscore2(Stringscore2){ this.score2=score2; } publicStringgetscore3(){ returnthis.score3; } publicvoidsetscore3(Stringscore3){ this.score3=score3; } publicStringgetscore4(){ returnthis.score4; } publicvoidsetscore4(Stringscore4){ this.score4=score4; } } classClass{ ArrayListstuList; publicClass(){ this.stuList=newArrayList<>(); } publicvoidaddStudent(Studentstu){ this.stuList.add(stu); } publicvoiddeleteStudent(Students){ this.stuList.remove(s); } } classmenuextendsJFrame{ publicmenu() { this.setBounds(300,150,500,450); this.setTitle("大连海事大学----学生信息管理系统"); this.setLayout(null); JLabellabTipw=newJLabel("欢迎进入大连海事大学学生信息管理系统"); labTipw.setBounds(50,2,250,45); JLabellabTipws=newJLabel("(*新用户初始密码为身份证后六位数字)"); labTipws.setBounds(50,15,250,45); JLabellabyonghu=newJLabel("用户名:"); labyonghu.setBounds(50,60,100,50); JTextFieldtxtyonghu=newJTextField("请输入登录用户名:",30); txtyonghu.setBounds(130,76,180,30); JLabellabmima=newJLabel("密码:"); labmima.setBounds(50,100,50,50); JTextFieldtxtmima=newJTextField("请输入登录6位密码:",30); txtmima.setBounds(130,117,180,30); JButtonbtndianji=newJButton("点击登录"); btndianji.setBounds(130,165,180,30); btndianji.setForeground(Color.BLUE); this.add(labTipw); this.add(labTipws); this.add(labyonghu); this.add(txtyonghu); this.add(labmima); this.add(txtmima); this.add(btndianji); btndianji.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ newStudentFrame();} }); setVisible(true); } } publicclassStudentFrameextendsJFrame{ Classc=newClass(); JLabellabNo; JLabellabName; JLabellabAge; JLabellabscore1; JLabellabscore2; JLabellabscore3; JLabellabscore4; JLabellabTip; JLabellabavr; JTextFieldtxtNo; JTextFieldtxtName; JTextFieldtxtAge; JTextFieldtxtscore1; JTextFieldtxtscore2; JTextFieldtxtscore3; JTextFieldtxtscore4; JTextFieldtxtavr; JButtonbtnAdd; JButtonbtnRemove; JButtonbtnModify; JButtonbtnClear; JButtonbtnFirst; JButtonbtnPrev; JButtonbtnNext; JButtonbtnLast; JButtonbtnCheck; JOptionPanedialog; publicStudentFrame(){ this.setBounds(300,100,650,530); this.setTitle("大连海事大学----学生信息管理系统"); this.setLayout(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); studentin(); addStu(); firstStudent(); lastStudent(); previous(); next(); remove(); check(); modify(); clear(); this.setVisible(true); } publicvoidstudentin(){ labTip=newJLabel("登陆成功!您已经进入管理系统(仅输入学号便可查找学生信息)."); labTip.setBounds(50,2,550,45); labNo=newJLabel("学生学号:"); labNo.setBounds(50,20,100,50); txtNo=newJTextField("请输入6位学号:",30); txtNo.setBounds(130,35,180,30); labName=newJLabel("学生姓名:"); labName.setBounds(50,60,100,50); txtName=newJTextField("请输入学生姓名:",30); txtName.setBounds(130,76,180,30); labAge=newJLabel("班级:"); labAge.setBounds(50,100,50,50); txtAge=newJTextField("请输入学生所在班级:",30); txtAge.setBounds(130,117,180,30); labscore1=newJLabel("JAVA成绩:"); labscore1.setBounds(50,140,100,50); txtscore1=newJTextField("请输入学生成绩:",30); txtscore1.setBounds(130,158,180,30); labscore2=newJLabel("C语言成绩:"); labscore2.setBounds(50,189,100,50); txtscore2=newJTextField("请输入学生成绩:",30); txtscore2.setBounds(130,199,180,30); labscore3=newJLabel("Python成绩:"); labscore3.setBounds(50,230,100,50); txtscore3=newJTextField("请输入学生成绩:",30); txtscore3.setBounds(130,240,180,30); labscore4=newJLabel("C++成绩:"); labscore4.setBounds(50,290,100,50); txtscore4=newJTextField("请输入学生成绩:",30); txtscore4.setBounds(130,301,180,30); labavr=newJLabel("操作说明**|<<:第一个学生信息<:上一位学生信息>:下一个学生信息>>|:最后一个学生信息"); labavr.setBounds(50,330,580,50); btnAdd=newJButton("添加"); btnAdd.setBounds(50,385,80,20); btnAdd.setForeground(Color.BLACK); btnModify=newJButton("修改"); btnModify.setBounds(150,385,80,20); btnModify.setForeground(Color.BLUE); btnRemove=newJButton("删除"); btnRemove.setBounds(250,385,80,20); btnRemove.setForeground(Color.RED); btnClear=newJButton("清空"); btnClear.setBounds(350,385,80,20); btnClear.setForeground(Color.GREEN); btnCheck=newJButton("查找信息"); btnCheck.setBounds(350,145,160,50); btnCheck.setForeground(Color.BLACK); btnFirst=newJButton("|<<"); btnFirst.setBounds(50,432,80,20); btnFirst.setForeground(Color.PINK); btnPrev=newJButton("<"); btnPrev.setBounds(150,432,80,20); btnPrev.setForeground(Color.BLACK); btnNext=newJButton(">"); btnNext.setBounds(250,432,80,20); btnNext.setForeground(Color.BLACK); btnLast=newJButton(">>|"); btnLast.setBounds(350,432,80,20); btnLast.setForeground(Color.PINK); this.add(labNo); this.add(labName); this.add(labAge); this.add(labscore1); this.add(txtNo); this.add(labTip); this.add(txtName); this.add(txtAge); this.add(txtscore1); this.add(btnAdd); this.add(btnRemove); this.add(btnModify); this.add(btnClear); this.add(btnFirst); this.add(btnPrev); this.add(btnNext); this.add(btnLast); this.add(btnCheck); this.add(labavr); this.add(labscore2); this.add(txtscore2); this.add(labscore3); this.add(txtscore3); this.add(labscore4); this.add(txtscore4); } publicbooleanblank(){ if(txtNo.getText().equals("")){ dialog.showMessageDialog(null,"学号输入有误请重新输入!"); returnfalse; } if(txtName.getText().equals("")){ dialog.showMessageDialog(null,"名字输入有误请重新输入!"); returnfalse; } if(txtAge.getText().equals("")){ dialog.showMessageDialog(null,"班级输入有误请重新输入!"); returnfalse; }if(txtscore1.getText().equals("")){ dialog.showMessageDialog(null,"成绩输入有误请重新输入!"); returnfalse; }if(txtscore2.getText().equals("")){ dialog.showMessageDialog(null,"成绩输入有误请重新输入!"); returnfalse; } if(txtscore3.getText().equals("")){ dialog.showMessageDialog(null,"成绩输入有误请重新输入!"); returnfalse; } if(txtscore4.getText().equals("")){ dialog.showMessageDialog(null,"成绩输入有误请重新输入!"); returnfalse; } returntrue; } publicvoidaddStu(){ btnAdd.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ if(blank()==true){ c.addStudent(newStudent(txtNo.getText(),txtName.getText(),txtAge.getText(),txtscore1.getText(),txtscore2.getText(),txtscore3.getText(),txtscore4.getText())); dialog.showMessageDialog(null,"学生信息已添加成功"); }}}); } publicvoidfirstStudent(){ btnFirst.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ txtNo.setText(c.stuList.get(0).getNo()); txtName.setText(c.stuList.get(0).getName()); txtAge.setText(c.stuList.get(0).getAge()); txtscore1.setText(c.stuList.get(0).getscore1()); txtscore2.setText(c.stuList.get(0).getscore2()); txtscore3.setText(c.stuList.get(0).getscore3()); txtscore4.setText(c.stuList.get(0).getscore4()); } }); } publicvoidlastStudent(){ btnLast.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ txtNo.setText(c.stuList.get(c.stuList.size()-1).getNo()); txtName.setText(c.stuList.get(c.stuList.size()-1).getName()); txtAge.setText(c.stuList.get(c.stuList.size()-1).getAge()); txtscore1.setText(c.stuList.get(c.stuList.size()-1).getscore1()); txtscore2.setText(c.stuList.get(c.stuList.size()-1).getscore2()); txtscore3.setText(c.stuList.get(c.stuList.size()-1).getscore3()); txtscore4.setText(c.stuList.get(c.stuList.size()-1).getscore4()); } }); } publicvoidprevious(){ btnPrev.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ intn=0; for(inti=0;i 0){ if(c.stuList.get(c.stuList.size()-1).getNo().equals(txtNo.getText())){ txtNo.setText(c.stuList.get(0).getNo()); txtName.setText(c.stuList.get(0).getName()); txtAge.setText(c.stuList.get(0).getAge()); txtscore1.setText(c.stuList.get(0).getscore1()); txtscore2.setText(c.stuList.get(0).getscore2()); txtscore3.setText(c.stuList.get(0).getscore3()); txtscore4.setText(c.stuList.get(0).getscore4()); }else{ txtNo.setText(c.stuList.get(a).getNo()); txtName.setText(c.stuList.get(a).getName()); txtAge.setText(c.stuList.get(a).getAge()); txtscore1.setText(c.stuList.get(a).getscore1()); txtscore2.setText(c.stuList.get(a).getscore2()); txtscore3.setText(c.stuList.get(a).getscore3()); txtscore4.setText(c.stuList.get(a).getscore4()); } }else{ clear(); } }else{ dialog.showMessageDialog(null,"未来找到对应学生的信息");}} } } }); } publicvoidmodify(){ btnModify.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ if(c.stuList.size()==0){ dialog.showMessageDialog(null,"没有该学生信息"); } for(Students:c.stuList){ if(s.getNo().equals(txtNo.getText())){ if(blank()==true){ s.setName(txtName.getText()); s.setAge(txtAge.getText()); JOptionPane.showMessageDialog(null,"已经修改成功"); return; } } } JOptionPane.showMessageDialog(null,"修改失败请重新操作"); } }); } publicvoidcheck(){ btnCheck.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ if((txtNo.getText().equals(""))){ dialog.showMessageDialog(null,"学号不能为空请从新输入"); }else{ intm=0; for(inti=0;i 关于管理系统的更多内容请点击《管理系统专题》进行学习
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。