java编写管理系统_用java编写学生信息管理系统

本文档介绍了一个用Java编写的简单学生信息管理系统,包括Studen类的定义,以及一个包含录入、查询、删除和修改功能的StudentManager类。系统使用JFrame、JButton等组件创建图形用户界面,并通过文件存储学生数据。
摘要由CSDN通过智能技术生成

《用java编写学生信息管理系统》由会员分享,可在线阅读,更多相关《用java编写学生信息管理系统(7页珍藏版)》请在人人文库网上搜索。

1、用java编写学生信息管理系统import .*;importimport .*;import .*;import .*;class Stude nt impleme ntsString nu mber, name,specialty,grade,borth,sex;public Stude nt();public void setNumber(Stri ng nu mber) =nu mber;public String getNumber() retur n nu mber;public void setName(Stri ng n ame) =n ame;public String ge。

2、tName() retur n n ame;public void setSex(Stri ng sex) =sex;public String getSex() retur n sex;public void setSpecialty(Stri ng specialty) =specialty;public String getSpecialty() retur n specialty;public void setGrade(Stri ng grade) =grade;public String getGrade() retur n grade;public void setBorth(S。

3、tri ng borth) =borth;public Stri ng getBorth() retur n borth;public class Stude ntMa nager exte nds JFrameJLabel lb=new JLabel (录入请先输入记录,查询、删除请先输入学号,修改是对查询” +内容改后的保存! ”);static JTextField Jnu mber, Jn ame,Jspecialty,Jgrade,Jborth;static JRadioButt on boy,girl;static Butt on Group group=nu II;static 。

4、JButton Log in, select,delete,update,show;static JPa nel p1,p2,p3,p4,p5,p6,pv,ph;static Stude nt stude nt=n ull;static Hashtable Shashtable=nu II;static File file=n ull;static File In putStream inOne=n ull;static Object In putStream in Two=n ull;static FileOutputStream out One=n ull;static ObjectOut。

5、putStream outTwo=n ull;public Stude ntMa nager()super(学生基本信息管理系统”);Jnu mber =new JTextField(10);Jname =new JTextField(10); Jspecialty=new JTextField(10); Jgrade=new JTextField(10); Jborth=new JTextField(10); group=new ButtonGroup(); boy=new JRadioButton( 男 ,true); girl=new JRadioButton( 女 ,false); (。

6、boy);(girl);Login=new JButton( 录入 ); select=new JButton( 查询 ); delete=new JButton( 删除 ); update=new JButton( 修改 ); show=new JButton( 显示 ); (new InputAct();(new InquestAct();(new ModifyAct();(new DeleteAct();(new ShowAct();(false); p1=new JPanel();(new JLabel(学号:,);(Jnumber); p2=new JPanel(); (new JL。

7、abel(姓名:,);(Jname); p3=new JPanel();(new JLabel(性别:,);(boy);(girl);p4=new JPanel();(new JLabel(专业:,);(Jspecialty); p5=new JPanel();(new JLabel(年级:,);(Jgrade); p6=new JPanel();(new JLabel(出生:,);(Jborth); pv=new JPanel();(new GridLayout(6,1);(p1);(p2);(p3);(p4);(p5);(p6);ph=new JPanel();(Login);(selec。

8、t);(update);(delete);(show);file=new File( 学生信息 .txt);Shashtable=new Hashtable();if(!()tryFileOutputStream out=new FileOutputStream(file);ObjectOutputStream objectOut=new ObjectOutputStream(out); (Shashtable);();();catch(IOException e)Container con=getContentPane();(new BorderLayout();(lb, ;(pv, ;(p。

9、h, ;setDefaultCloseOperation(EXIT_ON_CLOSE);setBounds(100,100,600,300);setVisible(true);public static void main(String args) new StudentManager();class InputAct implements ActionListenerpublic void actionPerformed(ActionEvent e)(false);String number=;number=();if()0)tryinOne=new FileInputStream(file。

10、);inTwo=new ObjectInputStream(inOne);Shashtable=(Hashtable)();();();catch(Exception ee) 创建散列表出现问题! ); if(number)String warning= 该生信息已存在,请到修改页面修改! (null,warning, 警告 ,Jquals(” 男)(true);else(true);else(false);String warning= 该学号不存在! ;(null,warning,警告 ,;else(false);String warning= 必须输入学号! ;(null,warning。

11、,警告 ,;class ModifyAct implements ActionListener public void actionPerformed(ActionEvent e)String number=();String name=();String specialty=();String grade=();String borth=();String sex=null;if()sex=();elsesex=();Student 学生 =new Student();学生 .setNumber(number);学生 .setName(name);学生 .setSpecialty(speci。

12、alty);学生 .setGrade(grade);学生 .setBorth(borth);学生 .setSex(sex);tryoutOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);(number, 学生 );(Shashtable);();();(null);(null);(null);(null);(null);catch(Exception ee)录入修改出现异常 !);(false);class DeleteAct implements ActionListenerpublic void act。

13、ionPerformed(ActionEvent e)(false);String number=();if()0)tryinOne=new FileInputStream(file); inTwo=new ObjectInputStream(inOne); Shashtable=(Hashtable)();();();catch(Exception ee)if(number)Student stu=(Student)(number);();();();();if().equals(” 男)(true);else(true);String m=确定要删除该学生的记录吗?”int ok=(nul。

14、l,m, 确认 ,J Jif(ok=(number);tryoutOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);(Shashtable);();();(null);(null);(null);(null);(null);catch(Exception ee)else if(ok=(null);(null);(null);(null);(null);elseString warning= 该学号不存在! ;(null,warning,n Ak n . 警告 ,;elseString warning= 必须。

15、输入学号! ;(null,warning,Ap, n . 警告 ,;class ShowAct implements ActionListenerpublic void actionPerformed(ActionEvent e)new StudentShow(file);class StudentShow extends JDialogHashtable 学生散列表 = null;JTextArea 显示 =null;FileInputStream inOne=null;ObjectInputStream inTwo=null;File file=null;public StudentSho。

16、w(File file)super(new JFrame(), 显示对话框 );=file;显示 =new JTextArea(16,30);tryinOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);学生散列表 =(Hashtable)();();();catch(Exception ee)n);if(学生散列表.isEmpty()显示.append(”目前还没有学生的信息记录! else显示.setText(”学号姓名性别专业年级出生n”);for(Enumeration enm= 学生散列表 .element。

17、s();();)Student stu=(Student)();String sex=;if().equals(男)sex=男;else sex=女;String str=()+,+()+,+sex+,+()+,+()+,+()+n;显示 .append(str);JScrollPane scroll=new JScrollPane显示);Container con=getContentPane();(Center,scroll);();setVisible(true);setBounds(200,200,400,300);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)setVisible(false);。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值