2022年JAVA学生管理源代码.docx
精品学习资源/Student_Management_System.java/JHelpTextPanel.java import java.awt.*;import java.awt.event.*;import javax.swing.*; import javax.swing.event.*;import java.io.*;/ 定义帮忙文档类class JHelpTextPanel extends JPanelFont newSmallTitleFont=new Font" JTextArea HelpText=new JTextArea楷体",Font.BOLD,12;JHelpTextPanelsetLayoutnull;setBackgroundColor.orange;HelpText.setBackgroundColor.orange;HelpText.setForegroundColor.red;HelpText.setFontnewSmallTitleFont;HelpText.setBounds0,0,600,600;addHelpText;/Student_InforPanel .javaimport java.awt.*; import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import java.io.*;class Student_InforPanel extends JPanel implements ActionListener/ 四种常用字体的定义Font newTitleFont=new Font"楷体",Font.BOLD,40; Font newSmallTitleFont=new Font"楷体",Font.BOLD,25 ;Font newCommonFont=new Font"宋体",Font.BOLD,20;欢迎下载精品学习资源Font newSubMenuFont=new Font" 宋体",Font.BOLD,15 ;Font NewSubMenuFont=new Font" 宋体",Font.BOLD,10 ;/ 性别数组定义String os="男 ","女 " ;/定义确认对话框图标ImageIcon thinker=new ImageIcon"ICON/thinker.gif";/定义同学信息治理系统面板菜单控件JLabel StudentSno_Clue=new JLabel"学号:" ;JLabel StudentName_Clue=new JLabel"姓名:" ;JLabel StudentSex_Clue=new JLabel"性别:" ;JLabel StudentAge_Clue=new JLabel"年龄:" ;JLabel StudentClass_Clue=new JLabel"班级:" ;JLabel StudentDept_Clue=new JLabel"系别:" ;JTextField StudentSno_Input=new JTextField;JTextField StudentName_Input=new JTextField;ComboBoxModel Othermode=new OtherAModel;JComboBox StudentSex_Input=new JComboBoxOthermode;JTextField StudentAge_Input=new JTextField;JTextField StudentClass_Input=new JTextField;JTextField StudentDept_Input=new JTextField;JTextArea QueryInforShow=new JTextArea;JLabel QueryClue=new JLabel"以下是你要查询的同学信息 :" ;JButton Add_StudentInformation=new JButton"增加同学信息 " ;JButton Del_StudentInformation=new JButton"删除同学信息 " ;JButton Query_StudentInformation=new JButton"查询同学信息 " ;JButton Modify_StudentInformation=new JButton"修改同学信息" ;/定义变量int ValidAge;String SnoOrigin;Student_InforPanelsetBackgroundColor.orange;QueryInforShow.setBackgroundColor.orange;setLayoutnull;StudentSno_Clue.setBounds270,120,80,30;StudentSno_Clue.setFontnewCommonFont ;StudentSno_Input.setBounds350,120,120,30;StudentName_Clue.setBounds270,170,80,30;StudentName_Clue.setFontnewCommonFont;欢迎下载精品学习资源StudentName_Input.setBounds350,170,120,30;StudentSex_Clue.setBounds270,220,80,30;StudentSex_Clue.setFontnewCommonFont ;StudentSex_Input.setBounds350,220,120,30;StudentAge_Clue.setBounds270,270,80,30;StudentAge_Clue.setFontnewCommonFont ;StudentAge_Input.setBounds350,270,120,30;StudentClass_Clue.setBounds270,320,80,30;StudentClass_Clue.setFontnewCommonFont;StudentClass_Input.setBounds350,320,120,30;StudentDept_Clue.setBounds270,370,80,30;StudentDept_Clue.setFontnewCommonFont ;StudentDept_Input.setBounds350,370,120,30;Query_StudentInformation.setBounds80,120,130,30;Query_StudentInformation.setFontnewSubMenuFont;Query_StudentInformation.addActionListenerthis;QueryClue.setBounds80,180,300,50;QueryClue.setFontnewSubMenuFont ;QueryInforShow.setBounds80,220,530,100;QueryInforShow.setFontnewSubMenuFont;Del_StudentInformation.setBounds80,120,130,30;Del_StudentInformation.setFontnewSubMenuFont;Del_StudentInformation.addActionListenerthis;Add_StudentInformation.setBounds80,170,130,30;Add_StudentInformation.setFontnewSubMenuFont;Add_StudentInformation.addActionListenerthis;Modify_StudentInformation.setBounds80,220,130,30;Modify_StudentInformation.setBounds80,220,130,30;Modify_StudentInformation.setFontnewSubMenuFont;Modify_StudentInformation.addActionListenerthis;addStudentSno_Clue ;addStudentSno_Input;addStudentName_Clue ;addStudentName_Input ;addStudentSex_Clue ;addStudentSex_Input;addStudentAge_Clue ;addStudentAge_Input;addStudentClass_Clue;addStudentClass_Input;addStudentDept_Clue;addStudentDept_Input;欢迎下载精品学习资源addQueryClue ;addQueryInforShow ;addAdd_StudentInformation;addDel_StudentInformation;addQuery_StudentInformation;addModify_StudentInformation;public void actionPerformedActionEvent eife.getSource=Add_StudentInformationifIsValidAgeStudentAge_Input.getTextString *=StringStudentSex_Input.getSelectedItem;MainMenu.myDatabase.Add_Database_InformationStudentSno_Input.ge tText,StudentName_Input.getText,*,ValidAge,StudentClass_Input.getT ext,StudentDept_Input.getText;emptyInput;ife.getSource=Del_StudentInformationQueryInforShow.setText"";ifMainMenu.myDatabase.Query_Database_InformationStuden tSno_Input.getTextQueryInforShow.setTextDataBaseControl.temptInformation;int result=JOptionPane.showConfirmDialognull,"你确定要删除该生信息吗? ","ConfirmMessage",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,think er ;ifresult=JOptionPane.YES_OPTIONifMainMenu.myDatabase.Del_Database_InformationSt udentSno_Input.getTextJOptionPane.showMessageDialognull,"删除操作成功!","Happy Message",JOptionPane.PLAIN_MESSAGE;elseJOptionPane.showMessageDialognull,"数据库操作显现反常,删除操作失败! ","Error Message",JOptionPane.ERROR_MESSAGE;else欢迎下载精品学习资源息." ;QueryInforShow.setText"对不起,没有找到你要删除的同学信欢迎下载精品学习资源ife.getSource=Query_StudentInformationQueryInforShow.setText"";ifMainMenu.myDatabase.Query_Database_InformationStud entSno_Input.getTextQueryInforShow.setTextDataBaseControl.temptInformatio欢迎下载精品学习资源n ;信息" ;elseQueryInforShow.setText"对不起,没有你想要查询的同学欢迎下载精品学习资源ife.getSource=Modify_StudentInformationifIsValidAgeStudentAge_Input.getTextMainMenu.myDatabase.Modify_Database_InformationSnoOri gin,StudentSno_Input.getText,StudentName_Input.getText,ValidAge,StudentClass_Inpu t.getText,StudentDept_Input.getText;欢迎下载精品学习资源trypublic boolean IsValidAgeString StringAgeValidAge=Integer.parseIntStringAge;欢迎下载精品学习资源catchNumberFormatException ee.printStackTrace;return false;ifValidAge<=120&ValidAge>0 return true;elseJOptionPane.showMessageDialognull,"你输入的年龄不合实际情形 n请重新输入 .","WARNING MESSAGE",JOptionPane.WARNING_MESSAG;E return false;欢迎下载精品学习资源class OtherAModel extends DefaultComboBoxModelOtherAModelforint i=0;i<os.length;i+ addElementosi;public void emptyInputStudentSno_Input.setText"";StudentAge_Input.setText"";StudentName_Input.setText"";StudentClass_Input.setText"";StudentDept_Input.setText"";public void OnlyShowSnoStudentSno_Clue.setVisibletrue;StudentSno_Input.setVisibletrue;StudentSno_Input.setText"";QueryClue.setVisibletrue;QueryInforShow.setVisibletrue;StudentName_Clue.setVisiblefalse;StudentName_Input.setVisiblefalse;StudentSex_Clue.setVisiblefalse;StudentSex_Input.setVisiblefalse;StudentAge_Clue.setVisiblefalse;StudentAge_Input.setVisiblefalse;StudentClass_Clue.setVisiblefalse;StudentClass_Input.setVisiblefalse;StudentDept_Clue.setVisiblefalse;StudentDept_Input.setVisiblefalse;/显示同学信息的全部面板控件public void ShowWholeStudentSno_Clue.setVisibletrue;StudentSno_Input.setVisibletrue;StudentSno_Input.setText"";QueryClue.setVisiblefalse;欢迎下载精品学习资源QueryInforShow.setVisiblefalseStudentName_Clue.setVisibletrue;StudentName_Input.setVisibletrue;StudentName_Input.setText"";StudentSex_Clue.setVisibletrue;StudentSex_Input.setVisibletrue;StudentAge_Clue.setVisibletrue;StudentAge_Input.setVisibletrue;StudentAge_Input.setText"";StudentClass_Clue.setVisibletrue;StudentClass_Input.setVisibletrueStudentClass_Input.setText"";StudentDept_Clue.setVisibletrue;StudentDept_Input.setVisibletrue;StudentDept_Input.setText"";/Student_ScorePanel.javaimport java.awt.*; import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;class Student_ScorePanel extends JPanel implements ActionListener/ 三种常用字体的定义Font newTitleFont=new Font"楷体",Font.BOLD,40; Font newSmallTitleFont=new Font"楷体",Font.BOLD,25 ;Font newCommonFont=new Font"宋体",Font.BOLD,20; Font newSubMenuFont=new Font" 宋体",Font.BOLD,15 ;Font NewSubMenuFont=new Font" 宋体",Font.BOLD,10 ;/定义确认对话框图标ImageIcon thinker=new ImageIcon"ICON/thinker.gif";JLabel ScoreSno_Clue=new JLabel"学号:" ;JLabel ScoreEnglish_Clue=new JLabel"英语:" ;JLabel ScoreSeniorMath_Clue=new JLabel"高数:" ;JLabel ScoreC_Clue=new JLabel"C:";JLabel ScoreVC_Clue=new JLabel"VC:";JLabel ScoreJAVA_Clue=new JLabel"JAVA:";欢迎下载精品学习资源JTextField ScoreSno_Input=new JTextField;JTextField ScoreEnglish_Input=new JTextField;JTextField ScoreSeniorMath_Input=new JTextField;JTextField ScoreC_Input=new JTextField; JTextField ScoreVC_Input=new JTextField;JTextField ScoreJAVA_Input=new JTextField;JTextArea ScoreShow=new JTextArea;JLabel ScoreShowClue=new JLabel"你要查询的同学成果信息为 :" ;JButton Add_ScoreInformation=new JButton"增加同学成果 " ;JButton Del_ScoreInformation=new JButton"删除同学成果 " ;JButton Query_ScoreInformation=new JButton"查询同学成果 " ;JButton Modify_ScoreInformation=new JButton"修改同学成果 " ;/定义变量int ValidScore;String ScoreSno;Student_ScorePanel/ 同学成果治理面板设置控件setBackgroundColor.orange;ScoreShow.setBackgroundColor.orange;setLayoutnull;ScoreSno_Clue.setBounds270,120,80,30;ScoreSno_Clue.setFontnewCommonFont ;ScoreSno_Input.setBounds350,120,120,30;ScoreEnglish_Clue.setBounds270,170,80,30;ScoreEnglish_Clue.setFontnewCommonFont;ScoreEnglish_Input.setBounds350,170,120,30;ScoreSeniorMath_Clue.setBounds270,220,80,30;ScoreSeniorMath_Clue.setFontnewCommonFont ;ScoreSeniorMath_Input.setBounds350,220,120,30;ScoreC_Clue.setBounds270,270,80,30;ScoreC_Clue.setFontnewCommonFont ;ScoreC_Input.setBounds350,270,120,30;ScoreVC_Clue.setBounds270,320,80,30;ScoreVC_Clue.setFontnewCommonFont;ScoreVC_Input.setBounds350,320,120,30;ScoreJAVA_Clue.setBounds270,370,80,30;ScoreJAVA_Clue.setFontnewCommonFont;ScoreJAVA_Input.setBounds350,370,120,30;Query_ScoreInformation.setBounds80,120,130,30;Query_ScoreInformation.setFontnewSubMenuFont;Query_ScoreInformation.addActionListenerthis;欢迎下载精品学习资源ScoreShowClue.setFontnewSubMenuFont ;ScoreShowClue.setBounds80,180,300,50;ScoreShow.setFontnewSubMenuFont ;ScoreShow.setBounds80,220,530,100;Del_ScoreInformation.setBounds80,120,130,30;Del_ScoreInformation.setFontnewSubMenuFont;Del_ScoreInformation.addActionListenerthis;Add_ScoreInformation.setBounds80,170,130,30;Add_ScoreInformation.setFontnewSubMenuFont;Add_ScoreInformation.addActionListenerthis;Modify_ScoreInformation.setBounds80,220,130,30;Modify_ScoreInformation.setFontnewSubMenuFont;Modify_ScoreInformation.addActionListenerthis;addScoreSno_Clue ;addScoreSno_Input;addScoreEnglish_Clue;addScoreEnglish_Input;addScoreSeniorMath_Clue;addScoreC_Clue ;addScoreSeniorMath_Input;addScoreC_Input;addScoreVC_Clue ;addScoreVC_Input;addScoreJAVA_Clue ;addScoreJAVA_Input;addScoreShow ;addScoreShowClue ;addAdd_ScoreInformation;addDel_ScoreInformation;addQuery_ScoreInformation;addModify_ScoreInformation;public void actionPerformedActionEvent eife.getSource=Query_ScoreInformation/查询按纽大事触发处理欢迎下载精品学习资源ifMainMenu.myDatabase.QueryScoreFunctionScoreSno_Input.getTextScoreShow.setText"";ScoreShow.append" 学号tt英语t高数tCtVCtJAVAn";ScoreShow.appendMainMenu.myDatabase.Student_ScoreMainMenu.my欢迎下载精品学习资源Database.NowScoreNum;elseScoreShow.setText"";ScoreShow.setText"对不起,没有你想要查找的同学信息 ." ;ife.getSource=Add_ScoreInformation/增加同学成果信息按纽的时间触发ifIsValidScoreScoreEnglish_Input.getText&&IsValidScoreScor eSeniorMath_Input.getText&&IsValidScoreScoreC_Input.getText&&IsValidScoreScoreVC_Input.getText&&IsValidScoreScoreJAVA_Input.getTextIsValidScoreScoreEnglish_Input.getText;int englishscore=ValidScore;IsValidScoreScoreSeniorMath_Input.getText;int seniorscore=ValidScore;IsValidScoreScoreC_Input.getText;int cscore=ValidScore;IsValidScoreScoreVC_Input.getText; int vcscore=ValidScore;IsValidScoreScoreJAVA_Input.getText;int javascore=ValidScore;MainMenu.myDatabase.addStudentScoreInformationScoreSno_Inpu t.getText,englishscore,seniorscore, cscore, vcscore, javascore;emptyInput;ife.getSource=Del_ScoreInformation/删除同学成果信息大事触发处理欢迎下载精品学习资源ifMainMenu.myDatabase.QueryScoreFunctionScoreSno_Input.getTextScoreShow.setText"";ScoreShow.append" 学号tt英语t高数tCtVCtJAVAn";ScoreShow.appendMainMenu.myDatabase.Student_ScoreMainMenu.my欢迎下载精品学习资源Database.NowScoreNum;int result=JOptionPane.showConfirmDialognull,"你真的要删除该同学的成果信息吗? ","Confirm Message",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,thinker;ifresult=JOptionPane.YES_OPTION欢迎下载精品学习资源 ;elseMainMenu.myDatabase.DelScoreFunctionScoreSno_Input.getText欢迎下载精品学习资源ScoreShow.setText"";ScoreShow.setText"对不起,你要删除的同学成果信息不存在!" ;ife.getSource=Modify_ScoreInformation/修改数据库中同学成果信息大事的触发ifIsValidScoreScoreEnglish_Input.getText&&IsValidScoreScor eSeniorMath_Input.getText&&IsValidScoreScoreC_Input.getText&&IsValidScoreScoreVC_Input.getT ext&&IsValidScoreScoreJAVA_Input.getTextIsValidScoreScoreEnglish_Input.getText;int englishscore=ValidScore;IsValidScoreScoreSeniorMath_Input.getText;int seniorscore=ValidScore;IsValidScoreScoreC_Input.getText;int cscore=ValidScore;IsValidScoreScoreVC_Input.getText; int vcscore=ValidScore;IsValidScoreScoreJAVA_Input.getText;int javascore=ValidScore;MainMenu.myDatabase.ModifyStudentScoreInformationScor eSno_Input.getText,ScoreSno,englishscore,seniorscore, cscore, vcscore,欢迎下载精品学习资源javascore;emptyInput;欢迎下载精品学习资源public boolean IsValidScoreString stringAge/判定成果输入是否合法tryValidScore=Integer.parseIntstringAge;catchNumberFormatException e欢迎下载精品学习资源JOptionPane.showMessageDialognull,"成果输入中含有非