【Java精品源码栏目提醒】:网学会员为广大网友收集整理了,用java做的学籍管理系统源码(有注释) - 其它资料,希望对大家有所帮助!
本系统有 6 个类,本系统主要功能:删除,修改,查询,添加。
管理员帐号:admin 密码:1234使用者下载
文档后,自行复制内容分别存为ManagerWindow.
java , Delete.
java , InputStudent.
java , Inquest.
java ,ModifySituation.
java,Student.
java 6 个类。
在运行时在工程根目录自行添加
管理系统的背景图quot123.jpgquot ,无图不错误。
本
系统由 西安欧亚学院 五块二 小组编写。
ManagerWindow.
java 主类package zuoye//主类import
java.awt.import
java.awt.event.import javax.swing.import
java.io.import
java.util.Hashtablepublic class ManagerWindow extends JFrame implements ActionListener InputStudent 基本信息录入null ModifySituation 基本信息修改null Inquest 基本信息查询null Delete 基本信息删除null JPanel pCenterpp9 TextField txtNametxtPassword Label lblTitlelblNamelblPassword Button btnSubmitbtnResetguanbi Panel p1p11p12p2p13p14p15 JMenuBar bar ImageIcon icon JMenu fileMenu JMenuItem 录入修改查询删除欢迎退出关于 Container connull Hashtable 基本信息null File filenull CardLayout cardnull JLabel labelnull JLabel label2 public ManagerWindow pnew JPanellblNamenew Labelquot管理员帐号:quottxtNamenew TextField10lblPasswordnew Labelquot密 码:quottxtPasswordnew TextField10txtPassword.setEchoCharbtnSubmit new Buttonquot提交quotbtnReset new Buttonquot重置quotguanbinew Buttonquot关闭quotp11new Panelp12new Panelp13new Panelp14new Panelp15new Panelp11.addlblNamep11.addtxtNamep12.addlblPasswordp12.addtxtPass
wordtxtName.addActionListenerthistxtPassword.addActionListenerthisp13.addbtnSubmitbtnSubmit.setBackgroundColor.YELLOWp13.addbtnResetbtnReset.setBackgroundColor.YELLOWp13.addguanbiguanbi.setBackgroundColor.YELLOWbtnSubmit.addActionListenerthisbtnReset.addActionListenerthisguanbi.addActionListenerthisp.setLayoutnew GridLayout101p.addp14p.addp15p.addp11p.addp12p.addp13p.setBackgroundColor.grayp9new JPaneliconnew ImageIconquot123.jpgquotlabel2new JLabeliconJLabel.LEFTlabelnew JLabelquot欢迎使用学生基本信息管理系统quotJLabel.CENTERlabel.setFontnew FontquotTimesRomanquotFont.BOLD24label.setForegroundColor.redp9.setOpaquetruep9.addlabel p9.addlabel2 录入new JMenuItemquot录入学生基本信息quot 修改new JMenuItemquot修改学生基本信息quot 查询new JMenuItemquot查询学生基本信息quot 删除new JMenuItemquot删除学生基本信息quot 欢迎new JMenuItemquot欢迎界面quot 退出new JMenuItemquot退出quot 关于new JMenuItemquot关于我们quot barnew JMenuBar fileMenunew JMenuquot菜单选项quot fileMenu.add录入 fileMenu.add修改 fileMenu.add查询 fileMenu.add删除 fileMenu.add欢迎 fileMenu.add关于 fileMenu.add退出 fileMenu.enablefalse bar.addfileMenu setJMenuBarbar 基本信息new Hashtable 录入.addActionListenerthis 修改.addActionListenerthis
查询.addActionListenerthis 删除.addActionListenerthis 欢迎.addActionListenerthis 退出.addActionListenerthis 关于.addActionListenerthis cardnew CardLayout congetContentPane pCenternew JPanel pCenter.setLayoutcard pCenter.setBackgroundColor.black filenew Filequot作业.txtquot //定义一个新的 文件,用来接收信息 iffile.exists try FileOutputStream outnew FileOutputStreamfile //这是一个文件输出流 ObjectOutputStream objectOutnew ObjectOutputStreamout //这是给文件里写内容的 objectOut.writeObject基本信息 //把读到的基本信息写入到文件中 objectOut.close out.close catchIOException e //捕捉异常 基本信息录入new InputStudentfile 基本信息修改new ModifySituationfile 基本信息查询new Inquestthisfile 基本信息删除new Deletefile pCenter.addpBorderLayout.CENTER pCenter.addquot欢迎语界面quotp9 pCenter.addquot录入界面quot基本信息录入 pCenter.addquot修改界面quot基本信息修改 pCenter.addquot删除界面quot基本信息删除 con.addpCenterBorderLayout.CENTER con.validate addWindowListenernew WindowAdapter public void windowClosingWindowEvent e System.exit0 setVisibletrue setBounds500200450400 setResizablefalse validate public void clear txtName.setTextquotquot txtPassword.setTextquotquot SuppressWarningsquotdeprecationquot public void submit //如果密码输对,则直接进入“欢迎页面”,菜单的按钮也变为可用 String ntxtName.getText String pawtxtPassword.getText ifn.equalsquotadminquot ampamp paw.equalsquot1234quot JOptionPane.showMessageDialogthisquot合法用户,欢迎进入本系统quot card.showpCenterquot欢迎语界面quot fileMenu.enabletrue //定义菜单按钮 变为可用 else JOptionPane.showMessageDialogthisquot非法用户,禁止进入本系统quot//如果密码输错,则进行提示 public void actionPerformedActionEvent e ife.getSource录入 card.showpCenterquot录入界面quot //如果选择录入,则显示录入页面,进行相应的操作 else ife.getSource修改 card.showpCenterquot修改界面quot //如果选择修改,则显示修改页面,进行相应的操作 else ife.getSource查询 基本信息查询.setVisibletrue //如果选择查询,则显示查询页面,进行相应的操作 else ife.getSource删除 card.showpCenterquot删除界面quot //如果选择录入,则显示录入页面,进行相应的操作 else ife.getSource欢迎 card.showpCenterquot欢迎语界面quot //如果选择录入,则显示录入页面,进行相应的操作 else ife.getSource退出 //如果选择退出,则直接退出 System.exit0 else ife.getSource关于 //如果选择关于,则显示提示信息“关于我们” JOptionPane.showMessageDialogthisquot王凯正quot String se.getActionCommand ifs.equalsquot重置quot //点击 重置 按钮,调用清除方法 clear clear else ifs.equalsquot提交quot //点击 提交 按钮,调用提交方法 submit submit else ife.getSourcetxtName //如果选择框在用户名输入框上,按回车 跳到 密码输入框上 txtPassword.requestFocus else ife.getSourcetxtPassword //如果选择框在密码输入框上,按回车 跳到 提示按钮 上,调用提交方法 submit submit else ifs.equalsquot关闭quot //点击 关闭 按钮,直接退出 System.exit0 public static void mainString args new ManagerWindow Delete.
java 删除信息类package zuoye//删除信息import
java.awt.import
java.awt.event.import javax.swing.import
java.io.import
java.util.public class Delete extends JPanel implements ActionListener Hashtable 基本信息表null JTextField 学号姓名专业年级出生 JRadioButton 男女 JButton 删除 ButtonGroup groupnull FileInputStream inOnenull ObjectInputStream inTwonull FileOutputStream outOnenull ObjectOutputStream outTwonull File filenull public DeleteFile file this.filefile 学号new JTextField10 //这一部分是窗口各部件的布置 删除new JButtonquot删除quot 学号.addActionListenerthis 删除.addActionListenerthis 姓名new JTextField10 姓名.setEditablefalse 专业new JTextField10 专业.setEditablefalse 年级new JTextField10 年级.setEditablefalse 出生new JTextField10 出生.setEditablefalse 男new JRadioButtonquot男quotfalse 女new JRadioButtonquot女quotfalse groupnew ButtonGroup group.add男 group.add女 Box box1Box.createHorizontalBox box1.addnew JLabelquot输入要删除的ENTER box1.add学号 box1.add删除 Box box2Box.createHorizontalBox box2.addnew JLabelquot姓名:quotJLabel.CENTER box2.add姓名 Box box3Box.createHorizontalBox box3.addnew JLabelquot性别:quotJLabel.CENTER box3.add男 box3.add女 Box box4Box.createHorizontalBox box4.addnew JLabelquot专业:quotJLabel.CENTER box4.add专业 Box box5Box.createHorizontalBox box5.addnew JLabelquot班级:quotJLabel.CENTER box5.add年级 Box box6Box.createHorizontalBox box6.addnew JLabelquot生日:quotJLabel.CENTER box6.add出生 Box boxHBox.createVerticalBox boxH.addbox1 boxH.addbox2 boxH.addbox3 boxH.addbox4 boxH.addbox5 boxH.addbox6 boxH.addBox.createVerticalGlue JPanel pCenternew JPanel pCenter.addboxH setLayoutnew BorderLayout addpCenterBorderLayout.CENTER validate public void actionPerformedActionEvent e ife.getSource删除e.getSource学号 //如果学号和删除俩事件同时满足,就进行删除 String numberquotquot number学号.getText ifnumber.lengthgt0 try inOnenew FileInputStreamfile //定义 inone 来将读写信息到 作业.txt inTwonew ObjectInputStreaminOne //定义 intwo 来获得的信息 基本信息表HashtableinTwo.readObject //用嘻哈表暂时存储 inone 获取的值 inOne.close //关闭 inone inTwo.close //关闭 intwo catchException ee //捕捉异常 if基本信息表.containsKeynumber //主键 number 学号的 基本信息表 ,用来暂时存储从
作业.txt 中读到的对应信息 Student stuStudent基本信息表.getnumber 姓名.setTextstu.getName //将读到的姓名显示到文本框 专业.setTextstu.getDisciping //将读到的专业显示到文本框 年级.setTextstu.getGrade //将读到的班级显示到文本框 出生.setTextstu.getBorth //将读到的生日显示到文本框 ifstu.getSex.equalsquot男quot //将读到的性别显示到文本框 男.setSelectedtrue else 女.setSelectedtrue String mquot确定要删除该学号及全部信息吗quot int okJOptionPane.showConfirmDialogthismquot 确 认quotJOptionPane.YES_NO_OPTION JOptionPane.QUESTION_MESSAGE ifokJOptionPane.YES_OPTION 基本信息表.removenumber //如果选择 是,删除信息,则将所有的信息和文本框置空 try outOnenew FileOutputStreamfile outTwonew ObjectOutputStreamoutOne outTwo.writeObject基本信息表 outTwo.close outOne.close 学号.setTextnull 姓名.setTextnull 专业.setTextnull 年级.setTextnull 出生.setTextnull catchException ee //捕捉异常,输出异常 System.out.printlnee else ifokJOptionPane.NO_OPTION //如果选择 否, 则将所有文本框置空 学号.setTextnull 姓名.setTextnull 专业.setTextnull 年级.setTextnull 出生.setTextnull else //如果没有找 到 你所输入的学号,则进行提示 String warningquot该学号不存在quot JOptionPane.showMessageDialogthiswarningquot 警 告quotJOptionPane.WARNING_MESSAGE else //如果你没有输入学号进行删除,则进行提示 String warningquot必须要输入学号quot JOptionPane.showMessageDialogthiswarningquot 警 告quotJOptionPane.WARNING_MESSAGE InputStudent.
java 录入信息类package zuoye//录入信息import
java.awt.import
java.awt.event.import javax.swing.import
java.io.import
java.util.public class InputStudent extends JPanel implements ActionListener Hashtable 基本信息表null JTextField 学号姓名专业年级出生 JRadioButton 男女 Student 学生null ButtonGroup groupnull JButton 录入重置 FileInputStream inOnenull ObjectInputStream inTwonull FileOutputStream outOnenull ObjectOutputStream outTwonull File filenull public InputStudentFile file this.filefile 学号new JTextField10 姓名new JTextField10 专业new JTextField10 年级new JTextField10 出生new JTextField10 groupnew ButtonGroup 男new JRadioButtonquot男quottrue 女new JRadioButtonquot女quotfalse group.add男 group.add女 录入new JButtonquot录入quot 重置new JButtonquot重置quot 录入.addActionListenerthis 重置.addActionListenerthis Box box1Box.createHorizontalBox box1.addnew JLabelquotENTER box1.add学号 Box box2Box.createHorizontalBox box2.addnew JLabelquot姓名:quotJLabel.CENTER box2.add姓名 Box box3Box.createHorizontalBox box3.addnew JLabelquot性别:quotJLabel.CENTER box3.add男 box3.add女 Box box4Box.createHorizontalBox box4.addnew JLabelquot专业:quotJLabel.CENTER box4.add专业 Box box5Box.createHorizontalBox //这一部分是窗口各部件的布置 box5.addnew JLabelquot班级:quotJLabel.CENTER box5.add年级 Box box6Box.createHorizontalBox box6.addnew JLabelquot生日:quotJLabel.CENTER box6.add出生 Box boxHBox.createVerticalBox boxH.addbox1 boxH.addbox2 boxH.addbox3 boxH.addbox4 boxH.addbox5 boxH.addbox6 boxH.addBox.createVerticalGlue JPanel pCenternew JPanel pCenter.addboxH setLayoutnew BorderLayout addpCenterBorderLayout.CENTER JPanel pSouthnew JPanel pSouth.add录入 pSouth.add重置 addpSouthBorderLayout.SOUTH validate public void actionPerformedActionEvent e ife.getSource录入 String numberquotquot number学号.getText ifnumber.lengthgt0 try inOnenew FileInputStreamfile //定义 inone 来将读写信息到 作业.txt inTwonew ObjectInputStreaminOne //定义 intwo 来获得的信息 基本信息表HashtableinTwo.readObject //用嘻哈表暂时存储 inone 获取的值 inOne.close //关闭 inone inTwo.close //关闭 intwo catchException ee //捕.