java学生学籍管理系统

上传人:go****e 文档编号:136846369 上传时间:2020-07-02 格式:DOC 页数:21 大小:99KB
返回 下载 相关 举报
java学生学籍管理系统_第1页
第1页 / 共21页
java学生学籍管理系统_第2页
第2页 / 共21页
java学生学籍管理系统_第3页
第3页 / 共21页
java学生学籍管理系统_第4页
第4页 / 共21页
java学生学籍管理系统_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《java学生学籍管理系统》由会员分享,可在线阅读,更多相关《java学生学籍管理系统(21页珍藏版)》请在金锄头文库上搜索。

1、主类;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.Hashtable;public class StudentManager extends JFrame implements ActionListenerStudentSituation 基本信息录入=null;ModifySituation 基本信息修改=null;Inquest 基本信息查询=null;Delete 基本信息删除=null;JMenuBar bar;JMenu fileMen

2、u;JMenuItem 录入,修改,查询,删除;Container con=null; Hashtable 基本信息=null;/存放基本信息的散列表File file=null;/存放散列表的文件CardLayout card=null;/卡片布局JLabel label=null;JPanel pCenter;public StudentManager()录入=new JMenuItem(录入学生基本信息);修改=new JMenuItem(修改学生基本信息);查询=new JMenuItem(查询学生基本信息);删除=new JMenuItem(删除学生基本信息);bar=new JMe

3、nuBar();fileMenu=new JMenu(菜单选项);fileMenu.add(录入);fileMenu.add(修改);fileMenu.add(查询);fileMenu.add(删除);bar.add(fileMenu);setJMenuBar(bar);label=new JLabel(欢迎使用学生基本信息管理系统,JLabel.CENTER);label.setFont(new Font( TimesRoman,Font.BOLD,24);label.setForeground(Color.red);基本信息=new Hashtable();录入.addActionList

4、ener(this);修改.addActionListener(this);查询.addActionListener(this);删除.addActionListener(this);card=new CardLayout();con=getContentPane();pCenter=new JPanel();pCenter.setLayout(card);file=new File(基本信息.txt);if(!file.exists()tryFileOutputStream out=new FileOutputStream(file);ObjectOutputStream objectOut

5、=new ObjectOutputStream(out);objectOut.writeObject(基本信息);objectOut.close();out.close();catch(IOException e)基本信息录入=new StudentSituation(file);基本信息修改=new ModifySituation(file);JFrame f=new JFrame();基本信息查询=new Inquest(f,file);基本信息删除=new Delete(file);pCenter.add(欢迎语界面,label);pCenter.add(录入界面,基本信息录入);pCe

6、nter.add(修改界面,基本信息修改);pCenter.add(删除界面,基本信息删除);con.add(pCenter,BorderLayout.CENTER);con.validate();addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););setVisible(true);setBounds(100,50,420,380);validate();public void actionPerformed(ActionEvent e)if(e.getSou

7、rce()=录入)card.show(pCenter,录入界面);else if(e.getSource()=修改)card.show(pCenter,修改界面);else if(e.getSource()=查询)基本信息查询.setVisible(true);/基本信息查询查询窗口设置为独立,便于用户查询else if(e.getSource()=删除)card.show(pCenter,删除界面);public static void main(String args)new StudentManager();录入界面:import java.awt.*;import java.awt.e

8、vent.*;import javax.swing.*;import java.io.*;import java.util.*;SuppressWarnings(unchecked) public class StudentSituation extends JPanel implements ActionListenerHashtable 基本信息表=null; /存放学生基本信息的散列表JTextField 学号,姓名,专业,年级,出生;JRadioButton 男,女;Student 学生=null;ButtonGroup group=null;JButton 录入,重置;FileInp

9、utStream inOne=null;ObjectInputStream inTwo=null;FileOutputStream outOne=null;ObjectOutputStream outTwo=null;File file=null;public StudentSituation(File file)this.file=file;学号=new JTextField(10);姓名=new JTextField(10);专业=new JTextField(10);年级=new JTextField(10);出生=new JTextField(10);group=new ButtonG

10、roup();男=new JRadioButton(男,true);女=new JRadioButton(女,false);group.add(男);group.add(女);录入=new JButton(录入);重置=new JButton(重置);录入.addActionListener(this);重置.addActionListener(this);Box box1=Box.createHorizontalBox();box1.add(new JLabel(学号:,JLabel.CENTER);box1.add(学号);Box box2=Box.createHorizontalBox(

11、);box2.add(new JLabel(姓名:,JLabel.CENTER);box2.add(姓名);Box box3=Box.createHorizontalBox();box3.add(new JLabel(性别:,JLabel.CENTER);box3.add(男);box3.add(女);Box box4=Box.createHorizontalBox();box4.add(new JLabel(专业:,JLabel.CENTER);box4.add(专业);Box box5=Box.createHorizontalBox();box5.add(new JLabel(年级:,JL

12、abel.CENTER);box5.add(年级);Box box6=Box.createHorizontalBox();box6.add(new JLabel(出生:,JLabel.CENTER);box6.add(出生);Box boxH=Box.createVerticalBox(); /创建一个垂直的box容器,其中从上向下排列 /6个水平box容器boxH.add(box1);boxH.add(box2);boxH.add(box3);boxH.add(box4);boxH.add(box5);boxH.add(box6);boxH.add(Box.createVerticalGlu

13、e();/垂直box容器内的组件靠上对齐JPanel pCenter=new JPanel();pCenter.add(boxH);setLayout(new BorderLayout();add(pCenter,BorderLayout.CENTER);JPanel pSouth=new JPanel();pSouth.add(录入);pSouth.add(重置);add(pSouth,BorderLayout.SOUTH);validate();public void actionPerformed(ActionEvent e)if(e.getSource()=录入)String number=;number=学号.getText();if(number.length()0)tryinOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);基本信息表=(Hashtable)inTwo.readObject();/首先到文件中读取hashtable对象 inOne.close();inTwo.close();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 幼儿/小学教育 > 其它小学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号