JAVA学生管理源代码整理.docx
《JAVA学生管理源代码整理.docx》由会员分享,可在线阅读,更多相关《JAVA学生管理源代码整理.docx(52页珍藏版)》请在冰豆网上搜索。
JAVA学生管理源代码整理
//Student_Management_System.java
//JHelpTextPanel.java
importjava.awt.*。
importjava.awt.event.*。
importjavax.swing.*。
importjavax.swing.event.*。
importjava.io.*。
//定义帮助文档类
classJHelpTextPanelextendsJPanel
{
FontnewSmallTitleFont=newFont("楷体",Font.BOLD,12)。
JTextAreaHelpText=newJTextArea()。
JHelpTextPanel()
{
setLayout(null)。
setBackground(Color.orange)。
HelpText.setBackground(Color.orange)。
HelpText.setForeground(Color.red)。
HelpText.setFont(newSmallTitleFont)。
HelpText.setBounds(0,0,600,600)。
add(HelpText)。
}
}
//Student_InforPanel.java
importjava.awt.*。
importjava.awt.event.*。
importjavax.swing.*。
importjavax.swing.event.*。
importjava.io.*。
classStudent_InforPanelextendsJPanelimplementsActionListener
{
//四种常用字体的定义
FontnewTitleFont=newFont("楷体",Font.BOLD,40)。
FontnewSmallTitleFont=newFont("楷体",Font.BOLD,25)。
FontnewCommonFont=newFont("宋体",Font.BOLD,20)。
FontnewSubMenuFont=newFont("宋体",Font.BOLD,15)。
FontNewSubMenuFont=newFont("宋体",Font.BOLD,10)。
//性别数组定义
Stringos[]={"男","女"}。
//定义确认对话框图标
ImageIconthinker=newImageIcon("ICON//thinker.gif")。
//定义学生信息管理系统面板菜单控件
JLabelStudentSno_Clue=newJLabel("学号:
")。
JLabelStudentName_Clue=newJLabel("姓名:
")。
JLabelStudentSex_Clue=newJLabel("性别:
")。
JLabelStudentAge_Clue=newJLabel("年龄:
")。
JLabelStudentClass_Clue=newJLabel("班级:
")。
JLabelStudentDept_Clue=newJLabel("系别:
")。
JTextFieldStudentSno_Input=newJTextField()。
JTextFieldStudentName_Input=newJTextField()。
ComboBoxModelOthermode=newOtherAModel()。
JComboBoxStudentSex_Input=newJComboBox(Othermode)。
JTextFieldStudentAge_Input=newJTextField()。
JTextFieldStudentClass_Input=newJTextField()。
JTextFieldStudentDept_Input=newJTextField()。
JTextAreaQueryInforShow=newJTextArea()。
JLabelQueryClue=newJLabel("以下是你要查询的学生信息:
")。
JButtonAdd_StudentInformation=newJButton("增加学生信息")。
JButtonDel_StudentInformation=newJButton("删除学生信息")。
JButtonQuery_StudentInformation=newJButton("查询学生信息")。
JButtonModify_StudentInformation=newJButton("修改学生信息")。
//定义变量
intValidAge。
StringSnoOrigin。
Student_InforPanel()
{
setBackground(Color.orange)。
QueryInforShow.setBackground(Color.orange)。
setLayout(null)。
StudentSno_Clue.setBounds(270,120,80,30)。
StudentSno_Clue.setFont(newCommonFont)。
StudentSno_Input.setBounds(350,120,120,30)。
StudentName_Clue.setBounds(270,170,80,30)。
StudentName_Clue.setFont(newCommonFont)。
StudentName_Input.setBounds(350,170,120,30)。
StudentSex_Clue.setBounds(270,220,80,30)。
StudentSex_Clue.setFont(newCommonFont)。
StudentSex_Input.setBounds(350,220,120,30)。
StudentAge_Clue.setBounds(270,270,80,30)。
StudentAge_Clue.setFont(newCommonFont)。
StudentAge_Input.setBounds(350,270,120,30)。
StudentClass_Clue.setBounds(270,320,80,30)。
StudentClass_Clue.setFont(newCommonFont)。
StudentClass_Input.setBounds(350,320,120,30)。
StudentDept_Clue.setBounds(270,370,80,30)。
StudentDept_Clue.setFont(newCommonFont)。
StudentDept_Input.setBounds(350,370,120,30)。
Query_StudentInformation.setBounds(80,120,130,30)。
Query_StudentInformation.setFont(newSubMenuFont)。
Query_StudentInformation.addActionListener(this)。
QueryClue.setBounds(80,180,300,50)。
QueryClue.setFont(newSubMenuFont)。
QueryInforShow.setBounds(80,220,530,100)。
QueryInforShow.setFont(newSubMenuFont)。
Del_StudentInformation.setBounds(80,120,130,30)。
Del_StudentInformation.setFont(newSubMenuFont)。
Del_StudentInformation.addActionListener(this)。
Add_StudentInformation.setBounds(80,170,130,30)。
Add_StudentInformation.setFont(newSubMenuFont)。
Add_StudentInformation.addActionListener(this)。
Modify_StudentInformation.setBounds(80,220,130,30)。
Modify_StudentInformation.setBounds(80,220,130,30)。
Modify_StudentInformation.setFont(newSubMenuFont)。
Modify_StudentInformation.addActionListener(this)。
add(StudentSno_Clue)。
add(StudentSno_Input)。
add(StudentName_Clue)。
add(StudentName_Input)。
add(StudentSex_Clue)。
add(StudentSex_Input)。
add(StudentAge_Clue)。
add(StudentAge_Input)。
add(StudentClass_Clue)。
add(StudentClass_Input)。
add(StudentDept_Clue)。
add(StudentDept_Input)。
add(QueryClue)。
add(QueryInforShow)。
add(Add_StudentInformation)。
add(Del_StudentInformation)。
add(Query_StudentInformation)。
add(Modify_StudentInformation)。
}
publicvoidactionPerformed(ActionEvente)
{
if(e.getSource()==Add_StudentInformation)
{
if(IsValidAge(StudentAge_Input.getText()))
{
String***=(String)StudentSex_Input.getSelectedItem()。
MainMenu.myDatabase.Add_Database_Information(StudentSno_Input.getText(),
StudentName_Input.getText(),***,ValidAge,StudentClass_Input.getText(),StudentDept_Input.getText())。
emptyInput()。
}
}
if(e.getSource()==Del_StudentInformation)
{
QueryInforShow.setText("")。
if(MainMenu.myDatabase.Query_Database_Information(StudentSno_Input.getText()))
{
QueryInforShow.setText(DataBaseControl.temptInformation)。
intresult=JOptionPane.showConfirmDialog(null,"你确定要删除该生信息吗?
","ConfirmMessage",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,thinker)。
if(result==JOptionPane.YES_OPTION)
{
if(MainMenu.myDatabase.Del_Database_Information(StudentSno_Input.getText()))
JOptionPane.showMessageDialog(null,"删除操作成功!
","HappyMessage",JOptionPane.PLAIN_MESSAGE)。
else
JOptionPane.showMessageDialog(null,"数据库操作出现异常,删除操作失败!
","ErrorMessage",JOptionPane.ERROR_MESSAGE)。
}
}
else
QueryInforShow.setText("对不起,没有找到你要删除的学生信息.")。
}
if(e.getSource()==Query_StudentInformation)
{
QueryInforShow.setText("")。
if(MainMenu.myDatabase.Query_Database_Information(StudentSno_Input.getText()))
QueryInforShow.setText(DataBaseControl.temptInformation)。
else
QueryInforShow.setText("对不起,没有你想要查询的学生信息")。
}
if(e.getSource()==Modify_StudentInformation)
{
if(IsValidAge(StudentAge_Input.getText()))
MainMenu.myDatabase.Modify_Database_Information(SnoOrigin,StudentSno_Input.getText(),
StudentName_Input.getText(),ValidAge,StudentClass_Input.getText(),StudentDept_Input.getText())。
}
}
publicbooleanIsValidAge(StringStringAge)
{
try
{
ValidAge=Integer.parseInt(StringAge)。
}catch(NumberFormatExceptione)
{
e.printStackTrace()。
returnfalse。
}
if(ValidAge<=120&ValidAge>0)
returntrue。
else
{
JOptionPane.showMessageDialog(null,"你输入的年龄不合实际情况\n请重新输入!
","WARNINGMESSAGE",
JOptionPane.WARNING_MESSAGE)。
returnfalse。
}
}
classOtherAModelextendsDefaultComboBoxModel
{
OtherAModel()
{
for(inti=0。
ii++)
addElement(os[i])。
}
}
publicvoidemptyInput()
{
StudentSno_Input.setText("")。
StudentAge_Input.setText("")。
StudentName_Input.setText("")。
StudentClass_Input.setText("")。
StudentDept_Input.setText("")。
}
publicvoidOnlyShowSno()
{
StudentSno_Clue.setVisible(true)。
StudentSno_Input.setVisible(true)。
StudentSno_Input.setText("")。
QueryClue.setVisible(true)。
QueryInforShow.setVisible(true)。
StudentName_Clue.setVisible(false)。
StudentName_Input.setVisible(false)。
StudentSex_Clue.setVisible(false)。
StudentSex_Input.setVisible(false)。
StudentAge_Clue.setVisible(false)。
StudentAge_Input.setVisible(false)。
StudentClass_Clue.setVisible(false)。
StudentClass_Input.setVisible(false)。
StudentDept_Clue.setVisible(false)。
StudentDept_Input.setVisible(false)。
}
//显示学生信息的所有面板控件
publicvoidShowWhole()
{
StudentSno_Clue.setVisible(true)。
StudentSno_Input.setVisible(true)。
StudentSno_Input.setText("")。
QueryClue.setVisible(false)。
QueryInforShow.setVisible(false)。
StudentName_Clue.setVisible(true)。
StudentName_Input.setVisible(true)。
StudentName_Input.setText("")。
StudentSex_Clue.setVisible(true)。
StudentSex_Input.setVisible(true)。
StudentAge_Clue.setVisible(true)。
StudentAge_Input.setVisible(true)。
StudentAge_Input.setText("")。
StudentClass_Clue.setVisible(true)。
StudentClass_Input.setVisible(true)。
StudentClass_Input.setText("")。
StudentDept_Clue.setVisible(true)。
StudentDept_Input.setVisible(true)。
StudentDept_Input.setText("")。
}
}
//Student_ScorePanel.java
importjava.awt.*。
importjava.awt.event.*。
importjavax.swing.*。
importjavax.swing.event.*。
classStudent_ScorePanelextendsJPanelimplementsActionListener
{
//三种常用字体的定义
FontnewTitleFont=newFont("楷体",Font.BOLD,40)。
FontnewSmallTitleFont=newFont("楷体",Font.BOLD,25)。
FontnewCommonFont=newFont("宋体",Font.BOLD,20)。
FontnewSubMenuFont=newFont("宋体",Font.BOLD,15)。
FontNewSubMenuFont=newFont("宋体",Font.BOLD,10)。
//定义确认对话框图标
ImageIconthinker=newImageIcon("ICON//thinker.gif")。
JLabelScoreSno_Clue=newJLabel("学号:
")。
JLabelScoreEnglish_Clue=newJLabel("英语:
")。
JLabelScoreSeniorMath_Clue=newJLabel("高数:
")。
JLabelScoreC_Clue=newJLabel("C:
")。
JLabelScoreVC_Clue=newJLabel("VC:
")。
JLabelScoreJAVA_Clue=newJLabel("JAVA:
")。
JTextFieldScoreSno_Input=newJTextField()。
JTextFieldScoreEnglish_Input=newJTextField()。
JTextFieldScoreSeniorMath_Input=newJTextField()。
JTextFieldScoreC_Input=newJTextField()。
JTextFieldScoreVC_Input=newJTextField()。
JTextFieldScoreJAVA_Input=newJTextField()。
JTextAreaScoreShow=newJTextArea()。
JLabelScoreShowClue=newJLabel("你要查询的学生成绩信息为:
")。
JButtonAdd_ScoreInformation=newJButton("增加学生成绩")。
JButtonDel_ScoreInformation=newJButton("删除学生成绩")。
JButtonQuery_ScoreInformation=newJButton