版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、java程序设计实验报告java programming assignment 专 业: 信息与计算科学 班 级: 1002班 学 号: 1008060207 姓 名: 屈敏华 2012年 6月 7 日1、 任务(问题)描述 设计一个图形用户界面来实现一个信息管理系统。这里我做的是学生信息管理系统。基本上实现学生信息的录入,修改,查询,删除。要求有类的继承,封装,接口的实现,还有基本的图形用户界面设计,要求用菜单条,菜单,下拉列表和基本的容器嵌套。为了使存储空间得到很好地利用,我采用散列表来实现对信息的基本的操作。二、设计与实现(多少个java文件,每个文件中的类)类 名属 性方 法备 注ma
2、nageinformationpublic static void mainstudentstring number,name,specialty,grade,borth,sex; public student()public void setnumberpublic string getnumberpublic void setnamepublic string getnamepublic void setsex public string getsexpublic void setspecialtypublic string getspecialtypublic void setgrade
3、public string getgradepublic void setborthpublic string getborth在student类里边有用另外一个类的对象作为这个类的成员变量,写在构造方法里 ,。 textjtextfield 学号,姓名,专业,年级,出生; jradiobutton 男,女; buttongroup group; jbutton 录入,查询,删除,修改,显示; jpanel p1,p2,p3,p4,p5,p6,pv,ph; student 学生; hashtable 学生散列表; file file;fileinputstream inone; objecti
4、nputstream intwo; fileoutputstream outone; objectoutputstream outtwo; public test()录入=new jbutton(录入); 录入.addactionlistener(new inputact(); p1=new jpanel(); p1.add(new jlabel(学号:,jlabel.center); trycatch(ioexception e) setdefaultcloseoperation(exit_on_close); setbounds(100,100,600,300); setvisible(t
5、rue); 继承了jframe,实现图形界面。deleteact public void actionperformed(actionevent e)setenabled()gettext()containskey()joptionpane.showconfirmdialogjoptionpane.yes_optionsystem.out.println()joptionpane.no_optionsetvisible() joptionpane.showmessagedialog删除信息inputact public void actionperformed(actionevent e)jo
6、ptionpane.showmessagedialog(null,warning,警告, joptionpane.warning_message); setvisible()录入inquestact public void actionperformed(actionevent e)setenabled()joptionpane.showmessagedialog()得到信息showact public void actionperformed(actionevent e)setvisible()显示信息studentshow isempty()windowclosingsetvisible(
7、)window button button1,button2,button3,button4,tuichu; panel p1,p2,p3; label l1,l2,l3; textfield a1,a2; box b1,b2,b3,b4,b5;setfont(new font(,font.bold,45); setbackground(color.white);dispose(); system.exit(0); getsource()gettext().equals( ) joptionpane.showmessagedialogpublic void windowclosing窗口 mo
8、difyactreadobject()isempty()append( )enm.hasmoreelements()修改信息附:源程序代码框架import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.*; import javax.swing.border.*; public class manageiformation public static void main(string args) new window(); class student string number,name,s
9、pecialty,grade,borth,sex; public student() new test(); ; public void setnumber(string number) this.number=number; public string getnumber() return number; 。public void setborth(string borth) this.borth=borth; public string getborth() return borth; class test extends jframe . public test() super(学生信息
10、管理系统); 学号=new jtextfield(10); . group.add(男); group.add(女); 录入.addactionlistener(new inputact(); . 修改.setenabled(false); p1=new jpanel(); p1.add(new jlabel(学号:,jlabel.center); p1.add(学号); . pv=new jpanel(); pv.setlayout(new gridlayout(6,1); pv.add(p1); . pv.add(p6); ph=new jpanel(); ph.add(录入); .fil
11、e=new file(学生信息.txt); 学生散列表=new hashtable(); if(!file.exists() try fileoutputstream out=new fileoutputstream(file); objectoutputstream objectout=new objectoutputstream(out); objectout.writeobject(学生散列表); objectout.close(); out.close(); catch(ioexception e) container con=getcontentpane(); con.setlayo
12、ut(new borderlayout(); . class inputact implements actionlistener public void actionperformed(actionevent e) 修改.setenabled(false); string number=; number=学号.gettext(); if(number.length()0) try inone=new fileinputstream(file); intwo=new objectinputstream(inone); 学生散列表=(hashtable)intwo.readobject(); i
13、none.close(); intwo.close(); catch(exception ee)system.out.println(创建散列表出现问题); if(学生散列表.containskey(number) string warning=该生信息已存在请到修改页面修改; joptionpane.showmessagedialog(null,warning,警告, joptionpane.warning_message); /end if1 else string m=该生信息将被录入; int ok=joptionpane.showconfirmdialog(null,m,确认, jo
14、ptionpane.yes_no_option,joptionpane.information_message); if(ok=joptionpane.yes_option) if(男.isselected()sex=男.gettext(); elsesex=女.gettext(); 学生=new student(); . try outone=new fileoutputstream(file); outtwo=new objectoutputstream(outone); 学生散列表.put(number,学生); outtwo.writeobject(学生散列表); outtwo.clo
15、se(); outone.close(); catch(exception ee)system.out.println(输出散列表出现问题); 学号.settext(null); 。. /end else1 /end if0 else string warning=信息不能为空; joptionpane.showmessagedialog(null,warning, 警告,joptionpane.warning_message); /end else0 /end actionperformed /end class class inquestact implements actionliste
16、ner public void actionperformed(actionevent e) string number=; . else 修改.setenabled(false); string warning=必须输入学号; joptionpane.showmessagedialog(null,warning, 警告,joptionpane.warning_message); class modifyact implements actionlistener public void actionperformed(actionevent e) try outone=new fileoutp
17、utstream(file); outtwo=new objectoutputstream(outone); 学生散列表.put(number, 学生); outtwo.writeobject(学生散列表); outtwo.close(); outone.close(); . atch(exception ee) system.out.println(录入修改出现异常!); 修改.setenabled(false); class deleteact implements actionlistener public void actionperformed(actionevent e) 修改.s
18、etenabled(false); string number=学号.gettext(); if(number.length()0) try inone=new fileinputstream(file); intwo=new objectinputstream(inone); 学生散列表=(hashtable)intwo.readobject(); inone.close(); intwo.close(); catch(exception ee) if(学生散列表.containskey(number) student stu=(student)学生散列表.get(number); . st
19、ring m=确定要删除该学生的记录吗; int ok=joptionpane.showconfirmdialog(null,m,确认, joptionpane.yes_no_option,joptionpane.question_message); if(ok=joptionpane.yes_option) 学生散列表.remove(number); try 。. catch(exception ee)system.out.println(ee); else if(ok=joptionpane.no_option) . 。 else string warning=该学号不存在; joptio
20、npane.showmessagedialog(null,warning,警告,joptionpane.warning_message); else string warning=必须输入学号; joptionpane.showmessagedialog(null,warning, 警告,joptionpane.warning_message); class showact implements actionlistener public void actionperformed(actionevent e) new studentshow(file); class studentshow e
21、xtends jdialog .try inone=new fileinputstream(file); intwo=new objectinputstream(inone); 学生散列表=(hashtable)intwo.readobject(); . catch(exception ee) if(学生散列表.isempty()显示.append(目前还没有学生的信息记录n); else for(enumeration enm=学生散列表.elements(); enm.hasmoreelements();) . jscrollpane scroll=new jscrollpane(显示); container con=getcontentpane(); . addwindowlistener(new windowadapter() public void windowclosing(windowevent e)setvisible(false); ); class window extends frame implements
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《GB-T 40831-2021资产管理 财务与非财务职能在资产管理活动中的一致性指南》专题研究报告
- 《GBT 15307-2008可转位钻头用削平直柄》专题研究报告
- 《GBT 15543-2008电能质量 三相电压不平衡》专题研究报告
- 道路安全交通法培训小结课件
- 2025年病理科工作总结及下一年工作计划
- 道路交通培训课件教学
- 道岔知识大全课件
- 逼单技巧和方法培训课件
- 达运安全培训课件
- 边境网络通信安全培训课件
- 2026年初二物理寒假作业(1.31-3.1)
- 2025秋人教版七年级上册音乐期末测试卷(三套含答案)
- 2025福建德化闽投抽水蓄能有限公司招聘4人(公共基础知识)综合能力测试题附答案
- “十五五规划纲要”解读:和美乡村宜居宜业
- 广东省广州市2026届高三年级上学期12月调研测试数学(广州零模)(含答案)
- 2025-2030中国工业硅行业市场现状供需分析及投资评估规划分析研究报告
- 手机供货协议书
- GJB3243A-2021电子元器件表面安装要求
- 国开大学2022年01月2136《管理会计》期末考试参考答案
- 狼疮性肾炎中医诊疗方案
- 健康相关生存质量及其测量和评价课件
评论
0/150
提交评论