用java编写学生信息管理系统_第1页
用java编写学生信息管理系统_第2页
用java编写学生信息管理系统_第3页
用java编写学生信息管理系统_第4页
用java编写学生信息管理系统_第5页
免费预览已结束,剩余2页可下载查看

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、用java编写学生信息管理系统import .*;importimport .*;import .*;import .*;class Student implementsString number,name,specialty,grade,borth,sex;public Student();public void setNumber(String number) =number;public String getNumber() return number;public void setName(String name) =name;public String getName() retur

2、n name;public void setSex(String sex) =sex;public String getSex() return sex;public void setSpecialty(String specialty) =specialty;public String getSpecialty() return specialty;public void setGrade(String grade) =grade;public String getGrade() return grade;public void setBorth(String borth) =borth;p

3、ublic String getBorth() return borth;public class StudentManager extends JFrameJLabel lb=new JLabel。录入请先输入记录,查询、删除请先输入学号,修改是对查询"+”内容改后的保存!");static JTextField Jnumber,Jname,Jspecialty,Jgrade,Jborth;static JRadioButton boy,girl;static ButtonGroup group=null;static JButton Login,select,delet

4、e,update,show;static JPanel p1,p2,p3,p4,p5,p6,pv,ph;static Student student=null;static Hashtable Shashtable=null;static File file=null;static FileInputStream inOne=null;static ObjectInputStream inTwo=null;static FileOutputStream outOne=null;static ObjectOutputStream outTwo=null;public StudentManager

5、()super("学生基本信息管理系统");Jnumber=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); (boy);(girl);Logi

6、n=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(&quo

7、t;学号:",); (Jnumber);p2=new JPanel();(new JLabel("姓名:",);(Jname);p3=new JPanel();(new JLabel("性另 k",);(boy);(girl);p4=new JPanel();(new JLabel("专业:",); (Jspecialty);p5=new JPanel();(new JLabel("年级:",);(Jgrade);p6=new JPanel();(new JLabel("出生:",);

8、(Jborth);pv=new JPanel();(new GridLayout(6,1);(p1);(p2);(p3);(p4);(p5);(p6);ph=new JPanel();(Login);(select);(update);(delete);(show);file=new File(" 学生信息.txt");Shashtable=new Hashtable();if(!()tryFileOutputStream out=new FileOutputStream(file);ObjectOutputStream objectOut=new ObjectOutput

9、Stream(out);(Shashtable);();();catch(IOException e)Container con=getContentPane();(new BorderLayout();(lb, ;(pv, ;(ph, ;setDefaultCloseOperation(EXIT_ON_CLOSE);setBounds(100,100,600,300);setVisible(true);public static void main(String args) new StudentManager();class InputAct implements ActionListen

10、erpublic void actionPerformed(ActionEvent e)(false);String number=""number=();if()>0)tryinOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);Shashtable=(Hashtable)();();();catch(Exception ee)" 创建散列表出现问题!");if(number)String warning="该生信息已存在,请到修改页面修改!(null,war

11、ning," 警告 ",quals("男")(true); else(true); else (false);String warning=" 该学号不存在!"(null,warning,警告 ,; else (false);String warning=" 必须输入学号!"(null,warning,警告 ,;class ModifyAct implements ActionListener public void actionPerformed(ActionEvent e)String number=();St

12、ring name=();String specialty=();String grade=();String borth=();String sex=null;if()sex=();elsesex=();Student 学生 =new Student();学生.setNumber(number);学生.setName(name);学生.setSpecialty(specialty);学生.setGrade(grade);学生.setBorth(borth);学生.setSex(sex);tryoutOne=new FileOutputStream(file);outTwo=new Objec

13、tOutputStream(outOne);(number, 学生 );(Shashtable);();();(null);(null);(null);(null);(null); catch(Exception ee) "录入修改出现异常!");(false);class DeleteAct implements ActionListener public void actionPerformed(ActionEvent e) (false);String number=();if()>0) try inOne=new FileInputStream(file);

14、inTwo=new ObjectInputStream(inOne);Shashtable=(Hashtable)();();();catch(Exception ee) if(number)Student stu=(Student)(number);();();();();if().equals("男")(true);else(true);String m="确定要删除该学生的记录吗?'int ok=(null,m," 确认 ",;if(ok=(number); tryoutOne=new FileOutputStream(file)

15、;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,警告 ,; elseString warning=" 必须输入学号!"(null,warning,警告 ,;class ShowAct implements

16、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 StudentShow(File file)super(new JFrame(),”显示对话框");=file;显示 =new

17、JTextArea(16,30);tryinOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);学生散列表=(Hashtable)();();();catch(Exception ee)if(学生散列表.isEmpty()显示.append("目前还没有学生的信息记录!n");else显示.setText("学号姓名性别专业年级出生n");for(Enumeration enm= 学生散列表.elements();();)Student stu=(Student)();String sex=""if().equals("男")sex="男"else sex="女";String str=()+","+()+","+sex+","+()+","+()+","+

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论