版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
--本页仅作为文档封面,使用时请直接删除即可--
--内页可以根据需求调整合适字体及大小本页仅作为文档封面,使用时请直接删除即可--
--内页可以根据需求调整合适字体及大小--电子日历记事本--Java课程设计(总26页)PAGE《面向对象程序设计》课程设计报告题目:电子日历记事本的设计院(系):信息科学与工程学院专业班级:计算机科学与技术1201班学生姓名:程伟学号:011指导教师:吴奕2014年12月29日至2015年1月9日华中科技大学武昌分校制面向对象程序设计课程设计任务书一、设计(调查报告/论文)题目电子日历记事本的设计二、设计(调查报告/论文)主要内容内容:设计GUI界面的日历记事本,系统将记事本与日历相结合,可在任何时间记载编辑或查看相关内容日志,系统可实现基本的辅助办公与行政管理。基本功能与要求:①设计记事本编辑器程序,所有编辑功能可以在菜单栏中选择,包括编辑、保存、打开、剪切、复制等操作,能打开和显示已存在的文本文件,界面设计要求采用类组件实现。②设计日历系统,要求用图形用户界面实现,用户可以方便地在任何日期编辑有关内容以及查看某个日期记载的内容。日历可以按年/月前后翻动,当鼠标单击“上一年/上一月”按钮时,当前日历的年份/月份将减一;当鼠标左键单击“下一年/下一月”按钮,当前日历的年份/月份将加一。③使用鼠标左键在要选择的日期上单击,如有记事内容,程序将弹出对话框提示用户是否用记事本显示该内容或编辑新内容,同时可将记事本的新内容保存起来,形成一个日志供用户日后使用。④设计用户密码功能或对信息内容加密,提高系统的安全性。三、原始资料1.《面向对象程序设计课程设计》指导书2.耿祥义.JAVA大学实用教程.北京:清华大学出版社,2009.四、要求的设计(调查/论文)成果1.课程设计报告2.课程设计软件五、进程安排布置任务,查找资料、需求分析1天总体设计1天详细设计天编制源程序实现天测试与修改1天撰写课设报告2天六、主要参考资料[1]张广彬.Java课程设计案例精编(第二版).北京:清华大学出版社,2011.[2]耿祥义.Java课程设计(第二版).北京:清华大学出版社,2008.[3]耿祥义.JAVA大学实用教程.北京:清华大学出版社,2009.[4]邹林达.陈国君Java2程序设计基础.北京:清华大学出版社,2010.[5]邹林达.Java2程序设计基础实验指导.北京:清华大学,2010.指导教师(签名):20年月日1需求与总体设计 1需求分析 1总体设计思路 1功能图 11.类图 22详细设计3CalendarPad类说明 3Year类说明 3Month类模块 4NotePad类说明 43编码实现 6CalendarPad模块 6Year模块 11Month模块 14NotePad模块 16系统运行与测试 23程序主界面 23日志查看——无日志 23建立日志 24日志查看——有日志 24删除日志 26总结 271需求与总体设计需求分析根据题目要求,将日历与记事本功能相结合,实现对某日期的事件进行记录的功能,设计出简洁方便美观的GUI界面。将本程序主界面可以分为四个部分:日历日期信息展示、年份、月份、记事本内容、记事本下方的时钟,用四个类来实现其“日历”和“记事本”这两大功能。通过主类CalendarPad创建动日历记事本软件的主界面,且该类中含有main方法,程序从该类开始执行。再用余下的year、mouth、NotePad类来显示并改变日期和实现记事本的功能。总体设计思路1.可以编辑日历的日期2.可以判断当前日期是否存在日志记录3.对有日志记录的日期,可以对该日期的日志记录进行修改和删除4.对没有日志记录的日期,可以创建并保存新建的日志记录5.对保存的日志加密,查看时得输入密码功能图类图
2详细设计CalendarPad类说明该模块设计主要主要包含以下成员变量:年(year)月(month)日(day) 存放日期的表(Hashtable) 存放日志的文件(File)主要方法有:创建程序主面板的构造方法(CalendarPad)处理ActionEvent事件的接口方法(actionPerformed)程序开始运行的main()方法。表1日历记事本系统主面板与日历板模块类名CalendarPadpublic接口MouseListenerpublic方法CalendarPad(int,int,int)设置日历牌(int,int)排列号码(int,int)main()publicpublicvoidpublicvoidpublicstaticvoidYear类说明该模块用于实现日历记事本系统中关于年的设置 模块中包含的主要成员变量有用于改变年的按钮(Jbutton明年去年),显示年的文本框(JTextField) 模块中包含的主要方法有用于设置年的方法(setYear),用于获取年的方法(getYear)和处理ActionEvent事件的接口方法(actionPerformed)等表2日历记事本系统年设置模块类名Yearpublic接口ActionListenerpublic方法setYear()getYear()actionPerformed(ActionEvente)publicvoidpublicintpublicvoidMonth类模块该模块用于实现日历记事本系统中关于月的设置模块中包含的主要成员变量有用于改变月的按钮(Jbutton上月下月),显示月的文本框(JTextField)模块中包含的主要方法有用于设置月的方法(setMonth),用于获取月的方法(getMonth)和处理ActionEvent事件的接口方法(actionPerformed)等表3日历记事本系统月设置模块类名Monthpublic接口ActionListenerpublic方法setMonth()getMonth()actionPerformed(ActionEvente)publicvoidpublicintpublicvoidNotePad类说明该模块中包含的主要成员变量有文本框(JTextArea),按钮(JButton保存日志删除日志),用于存放日志记录的文件(File)以及响应相关操作的信息提示(JLabel)该模块中包含的主要方法有设置信息条,设置文本区,获取日志内容,保存日志,删除日志表4日历记事本系统记事本模块类名NotePadpublic接口ActionListenerpublic方法设置信息条()设置文本区()获取日志内容()保存日志()删除日志()publicvoidpublicvoidpublicvoidpublicvoidpublicvoid
3编码实现源代码import.*;import.*;import.*;import.*;importclassCalendarPadextendsJFrameimplementsMouseListener{ intyear,month,day;etYear(year); 负责改变月=newMonth(this); 负责改变月.setMonth(month); title=newJLabel[7];etText(星期[j]); title[j].setBorder());etForeground; title[6].setForeground; for(inti=0;i<42;i++) { showDay[i]=newJTextField();ddMouseListener(this);etEditable(false);xt"); if(!()) (); (); } catch(IOExceptione) {} notepad=newNotePad(this); (notepad); 设置日历牌(year,month); addWindowListener(newWindowAdapter()et(year,month-1,1); 星期几=日历.get-1; if(month==1||month==2||month==3||month==5||month==7||month==8||month==10||month==12) { 排列号码(星期几,31); } elseif(month==4||month==6||month==9||month==11) { 排列号码(星期几,30); } elseif(month==2) { if((year%4==0&&year%100!=0)||(year%400==0)) { 排列号码(星期几,29); } else { 排列号码(星期几,28); } } } publicvoid排列号码(int星期几,int月天数) { for(inti=星期几,n=1;i<星期几+月天数;i++) { showDay[i].setText(""+n); if(n==day) { showDay[i].setForeground; showDay[i].setFont(newFont("TimesRoman",,20)); } else { showDay[i].setFont(newFont("TimesRoman",,12)); showDay[i].setForeground; } if(i%7==6) { showDay[i].setForeground; } if(i%7==0) { showDay[i].setForeground; } n++; } for(inti=0;i<星期几;i++) { showDay[i].setText(""); } for(inti=星期几+月天数;i<42;i++) { showDay[i].setText(""); } } publicintgetYear() { returnyear; } publicvoidsetYear(inty) { year=y; (year); } publicintgetMonth() { returnmonth; } publicvoidsetMonth(intm) { month=m; (month); } publicintgetDay() { returnday; } publicvoidsetDay(intd) { day=d; (day); } publicHashtablegetHashtable() { returnhashtable; } publicFilegetFile() { returnfile; } publicvoidmousePressed(MouseEvente) { JTextFieldsource=(JTextField)(); try { day=()); (day); notepad.设置信息条(year,month,day); notepad.设置文本区(null); notepad.获取日志内容(year,month,day); } catch(Exceptionee) {} } publicvoidmouseClicked(MouseEvente) {} publicvoidmouseReleased(MouseEvente) {} publicvoidmouseEntered(MouseEvente) {} publicvoidmouseExited(MouseEvente) {} publicstaticvoidmain(Stringargs[]) { Calendarcalendar=();历=日历;etYear();ddActionListener(this); 明年.addActionListener(this); } publicvoidsetYear(intyear) { =year; (""+year);etYear(year); 日历.设置日历牌(year,日历.getMonth()); } elseif()==明年) { year=year+1; (""+year); 日历.setYear(year); 日历.设置日历牌(year,日历.getMonth()); } elseif()==showYear) { try { year=()); (""+year); 日历.setYear(year); 日历.设置日历牌(year,日历.getMonth()); } catch(NumberFormatExceptionee) { (""+year); 日历.setYear(year); 日历.设置日历牌(year,日历.getMonth()); } } }}classMonthextendsBoximplementsActionListener{ intmonth; JTextFieldshowMonth=null; JButton下月,上月; CalendarPad日历; publicMonth(CalendarPad日历) { super; this.日历=日历; showMonth=newJTextField(2); month=日历.getMonth(); (false); ; (newFont("TimesRomn",,16)); 下月=newJButton("下月"); 上月=newJButton("上月"); add(上月); add(showMonth); add(下月); 上月.addActionListener(this); 下月.addActionListener(this); (""+month); } publicvoidsetMonth(intmonth) { if(month<=12&&month>=1) { =month; } else { =1; } (""+month); } publicintgetMonth() { returnmonth; } publicvoidactionPerformed(ActionEvente) { if()==上月) { if(month>=2) { month=month-1; 日历.setMonth(month); 日历.设置日历牌(日历.getYear(),month); } elseif(month==1) { month=12; 日历.setMonth(month); 日历.设置日历牌(日历.getYear(),month); } (""+month); } elseif()==下月) { if(month<12) { month=month+1; 日历.setMonth(month); 日历.设置日历牌(日历.getYear(),month); } elseif(month==12) { month=1; 日历.setMonth(month); 日历.设置日历牌(日历.getYear(),month); } (""+month); } }}classNotePadextendsJPanelimplementsActionListener{ JTextAreatext; JButton保存日志,删除日志; Hashtabletable; JLabel信息条; intyear,month,day; Filefile; CalendarPadcalendar; publicNotePad(CalendarPadcalendar) { =calendar; year=(); month=(); day=(); table=(); file=(); 信息条=newJLabel(""+year+"年"+month+"月"+day+"日",; 信息条.setFont(newFont("TimesRoman",,16)); 信息条.setForeground; text=newJTextArea(10,10); 保存日志=newJButton("保存日志"); 删除日志=newJButton("删除日志"); 保存日志.addActionListener(this); 删除日志.addActionListener(this); setLayout(newBorderLayout()); JPanelpSouth=newJPanel(); add(信息条,; (保存日志); (删除日志); add(pSouth,; add(newJScrollPane(text),; } publicvoidactionPerformed(ActionEvente) { if()==保存日志) { 保存日志(year,month,day); } elseif()==删除日志) { 删除日志(year,month,day); } } publicvoidsetYear(intyear) { =year; } publicintgetYear() { returnyear; } publicvoidsetMonth(intmonth) { =month; } publicintgetMonth() { returnmonth; } publicvoidsetDay(intday) { =day; } publicintgetDay() { returnday; } publicvoid设置信息条(intyear,intmonth,intday) { 信息条.setText(""+year+"年"+month+"月"+day+"日"); } publicvoid设置文本区(Strings) { (s); } publicvoid获取日志内容(intyear,intmonth,intday) { Stringkey=""+year+""+month+""+day; try { FileInputStreaminOne=newFileInputStream(file); ObjectInputStreaminTwo=newObjectInputStream(inOne); table=(Hashtable)(); (); (); } catch(Exceptionee) {} if(key)){Stringm=""+year+"年"+month+"月"+day+"这一天有日志记载,想看吗";intok=(this,m,"询问",,;if(ok=={ Stringstr=(null,"请输入密码","消息对话框",;longnum=(str); if(num!=123456){ (this,"密码不正确!","确认对话框",; } elseif(num==123456){ intn=(this,"确认正确吗","确认对话框",; ((String)(key)); } }else{("");}}else{("无记录");}} publicvoid保存日志(intyear,intmonth,intday) { String日志内容=(); Stringkey=""+year+""+month+""+day; Stringm=""+year+"年"+month+"月"+day+"保存日志吗"; intok=(this,m,"询问",,; if(ok== { try { FileInputStreaminOne=newFileInputStream(file); ObjectInputStreaminTwo=newObjectInputStream(inOne); table=(Hashtable)(); (); (); (key,日志内容); FileOutputStreamout=newFileOutputStream(file); ObjectOutputStreamobjectOut=newObjectOutputStream(out); (table); (); (); } catch(Exceptionee) {} } } publicvoid删除日志(intyear,intmonth,intday) { Stringkey=""+year+""+month+""+day; if(key)) { Stringm="删除"+year+"年"+month+"月"+day+"日的日志吗"; intok=(this,m,"询问",,; if(ok== { try { FileInputStreaminOne=newFileInputStream(file); ObjectInputStreaminTwo=newO
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电力工程造价员预算编制考试题目及答案
- 充电桩运维员设备维护考试题目及答案
- 卡尔多炉工安全生产意识竞赛考核试卷含答案
- 化工工艺试验工冲突解决能力考核试卷含答案
- 玻璃制品冷加工工安全生产基础知识强化考核试卷含答案
- 架线维护工复试评优考核试卷含答案
- 景泰蓝磨蓝工安全意识竞赛考核试卷含答案
- 农产品品相管理员变革管理知识考核试卷含答案
- 经济理论与实务2026年备考练习题
- 烟草物理检验员10S执行考核试卷含答案
- 铁路轨枕防腐施工方案
- 2026年淮南师范学院单招职业适应性考试题库1
- 全屋定制基本知识培训资料
- 2025年湖北雇员制审判辅助书记员考试综合能力测试题及答案
- 2025年保安证考试100题及答案
- 2025年广东电网有限责任公司春季校园招聘笔试参考题库附带答案详解
- 神经外科危重患者护理
- 赛迪译丛2025年第36期(总第711期):赢得人工智能竞赛:美国人工智能行动计划
- 脉冲射频治疗神经病理性疼痛的病例报告与分析
- 道路改造工程施工方案(3篇)
- 【装饰装修】技术部分(投标方案)
评论
0/150
提交评论