


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、JAVA程序设计课程设计报告专业:信息管理与信息系统班级:1124602学号:2姓名:邹玮指导教师:姜俊坡目录1 可行性分析 22 .需求分析功能23 .课程设计24. 编码 35. 系统验证21216. 总结1. 可行性分析1. 学习Java程序开发的环境搭建与配置,并且在实际运用中学习和和掌握 Java程序开发的过程2. 通过课程设计进一步掌握Java程序设计语言的基础内容,如用户图形界 面设计等3通过亲自设计,编写,调试程序来扩展知识面和动手操作能力2. 需求分析功能设计一个日历记事本.具体要求如下:1. 可以设置日历的日期2. 可以判断当前日期是否有日志记录3. 对有日志记录的日期,可
2、以对该日期的日志记录进行修改和删除4. 对没有日志记录的日期,可以创建并保存新建的日志记录3. 课程设计表1日历记事本系统主面板与日历板模块(Cale ndarPad.java类名Cale ndarPadpublic接口MouseListe nerpublicCale ndarPad(i nt, in t,i ntpublic方法设置日历牌(int,intpublic void排列号码(int,intpublic voidmain (public static void表2日历记事本系统年设置模块 (Year.java类名Yearpublic接口Actio nListe nerpublicse
3、tYear(public void方法getYear(public intactio nPeformed(Actio nEve nt epublic void表3日历记事本系统月设置模块(Month.java类名Mon thpublic接口Actio nListe nerpublicsetM on th(public void方法getM on th(public intactio nPeformed(Actio nEve nt epublic void表4日历记事本系统记事本模块(NotePad.java类名NotePadpublic接口Actio nListe nerpublic设置信息条
4、(public void设置文本区(public void方法获取日志内容(public void保存日志(public void删除日志(public void4. 编码1.日历记事本系统主面板与日历板模块(CalendarPad.java该模块设计主要主要包含以下成员变量:年(year月(month日(day存放日期的表 (Hashtable 存放日志的文件 (File主要方法有: 创建程序主面板的构造方法 CalendarPad ) 处理 ActionEvent 事件的接口方法 actionPerformed ) 程序开始运行的 main leftPanel=new JPanel( 。
5、JPanel leftCenter=new JPanel( 。 JPanel leftNorth=new JPanel( 。 leftCenter.setLayout(new GridLayout(7,7 。rightPanel=new JPanel( 。 this.year=year 。 this.month=month 。 this.day=day 。 负责改变年 =new Year(this 。 负责改变年 .setYear(year 。 负责改变月 =new Month(this 。 负责改变月 .setMonth(month 。 title=new JLabel7 。 showDay
6、=new JTextField42 。for(int j=0。 jtitlej=new JLabel( 。titlej.setText(星期j。titlej.setBorder(BorderFactory.createRaisedBevelBorder( 。leftCenter.add(titlej 。title0.setForeground(Color.red 。 title6.setForeground(Color.blue 。 for(int i=0 。 ishowDayi=new JTextField( 。 showDayi.addMouseListener(this 。 showDa
7、yi.setEditable(false 。 leftCenter.add(showDayi 。日历 =Calendar.getInstance( 。Box box=Box.createHorizontalBox( 。box.add( 负责改变年 。 box.add( 负责改变月 。leftNorth.add(box 。 leftPanel.setLayout(new BorderLayout( 。 leftPanel.add(leftNorth,BorderLayout.NORTH 。 leftPanel.add(leftCenter,BorderLayout.CENTER 。 leftPa
8、nel.add(new Label( 请在年份输入框输入所查年份(负数表示公元前 ,并回车确定 ,BorderLayout.SOUTH 。leftPanel.validate( 。Container con=getContentPane( 。JSplitPane split=newJSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPanel,rightPanel con.add(split,BorderLayout.CENTER 。 con.validate( 。hashtable=new Hashtable( 。file=new File( 日历记事本 .
9、txt 。if(!file.exists(tryFileOutputStream out=newFileOutputStream(file 。ObjectOutputStream objectOut=newObjectOutputStream(out 。objectOut.writeObject(hashtable 。objectOut.close( 。 out.close( 。catch(IOException enotepad=new NotePad(this 。rightPanel.add(notepad 。设置日历牌 (year,month 。addWindowListener(new
10、 WindowAdapter(public void windowClosing(WindowEvent eSystem.exit(0 。setVisible(true 。setBounds(100,50,524,285 。validate( 。public void 设置日历牌 (int year,int month日历 .set(year,month-1,1 。星期几二日历.get(Cale ndar.DAY_0F_WEEK-1 。if(month=1|month=2|month=3|month=5|month=7|month=8|month=10|month=12排列号码(星期几,31。
11、elseif(month=4|month=6|month=9|month=11排列号码(星期几,30。else if(month=2if(year%4=0&year%100!=0|(year%400=0排列号码(星期几,29。else排列号码(星期几,28。public void 排列号码 (int 星期几 ,int 月天数 for(int i=星期几,n=1。ishowDayi.setText(+nif(n=dayshowDayi.setForeground(Color.green 。showDayi.setFont(new Font(TimesRoman,Font.BOLD,20 。 el
12、seshowDayi.setFont(new Font(TimesRoman,Font.BOLD,12 。showDayi.setForeground(Color.black 。 if(i%7=6showDayi.setForeground(Color.blue 。 if(i%7=0showDayi.setForeground(Color.red 。 n+。for(int i=0。ishowDayi.setText( 。 for(int i= 星期几 +月天数。 ishowDayi.setText( 。 public int getYear(return year 。 public void
13、setYear(int y year=y 。 notepad.setYear(year 。 public int getMonth(return month 。 public void setMonth(int m month=m 。 notepad.setMonth(month 。 public int getDay(return day 。 public void setDay(int d day=d 。 notepad.setDay(day 。 public Hashtable getHashtable(return hashtable 。 public File getFile(ret
14、urn file 。public void mousePressed(MouseEvent e JTextField source=(JTextFielde.getSource(tryday=Integer.parseInt(source.getText( 。 notepad.setDay(day 。 notepad. 设置信息条 (year,month,day 。 notepad. 设置文本区 (null 。 notepad. 获取日志内容 (year,month,day 。 catch(Exception eepublic void mouseClicked(MouseEve nt epu
15、blic void mouseReleased(MouseEve nt e public void mouseEntered(MouseEvent e public void mouseExited(MouseEvent e public static void main(String argsCalendar calendar=Calendar.getInstance( 。 int y=calendar.get(Calendar.YEAR 。 int m=calendar.get(Calendar.MONTH+1 。 int d=calendar.get(Calendar.DAY_OF_MO
16、NTH 。 new CalendarPad(y,m,d 。2. 日历记事本系统年设置模块 (Year.java 该模块用于实现日历记事本系统中关于年的设置 模块中包含的主要成员变量有用于改变年的按钮 (Jbutton 明年 去年 ,显 示年的文本框 (JTextField模块中包含的主要方法有用于设置年的方法 (setYear, 用于获取年的方 法(getYear 和处理 ActionEvent 事件的接口方法(actionPeformed 等 实现编码如下 :import javax.swing.* 。import java.awt.* 。import java.awt.event.* 。p
17、ublic class Year extends Box implements ActionListenerint year 。JTextField showYear=null 。JButton 明年 ,去年。CalendarPad 日历。public Year(CalendarPad 日历 super(BoxLayout.X_AXIS 。 showYear=new JTextField(4 。 showYear.setForeground(Color.blue 。 showYear.setFont(new Font(TimesRomn,Font.BOLD,14 this. 日历=日历。yea
18、r=日历.getYear(。明年=new JButton(” 下年。去年 =new JButton( 上年。add(去年。add(showYear 。add(明年。showYear.addActionListener(this 。去年 .addActionListener(this 。明年.addActionListener(this 。public void setYear(int yearthis.year=year 。showYear.setText(+year 。public int getYear(return year 。public void actionPerformed(Ac
19、tionEvent eif(e.getSource(= 去年year=year-1 。showYear.setText(+year 。日历 .setYear(year 。日历.设置日历牌(year,日历.getMonth(。else if(e.getSource(= 明年year=year+1 。 showYear.setText(+year 。 日历 .setYear(year 。 日历 .设置日历牌 (year, 日历 .getMonth( 。else if(e.getSource(=showYeartryyear=Integer.parseInt(showYear.getText( 。
20、showYear.setText(+year 。 日历 .setYear(year 。日历 .设置日历牌 (year, 日历 .getMonth( 。 catch(NumberFormatException eeshowYear.setText(+year 。 日历 .setYear(year 。 日历 .设置日历牌 (year, 日历 .getMonth( 。 3. 日历记事本系统月设置模块 (Month.java该模块用于实现日历记事本系统中关于月的设置 模块中包含的主要成员变量有用于改变月的按钮 (Jbutton 上月 下月,显 示月的文本框 (JTextField模块中包含的主要方法有
21、用于设置月的方法 (setMonth, 用于获取月的方法(getMonth 和处理 ActionEvent 事件的接口方法(actionPeformed 等 实现编码如下 :import javax.swing.import java.awt.* 。import java.awt.event.* 。public class Month extends Box implements ActionListenerint month 。JTextField showMonth=null 。JButton 下月 ,上月。CalendarPad 日历。public Month(CalendarPad 日
22、历 super(BoxLayout.X_AXIS 。this. 日历=日历。showMonth=new JTextField(2 。month= 日历 .getMonth( 。showMonth.setEditable(false 。 showMonth.setForeground(Color.blue 。showMonth.setFont(new Font(TimesRomn,Font.BOLD,16 下月=new JButton(” 下月。上月 =new JButton( 上月 。add( 上月 。add(showMonth 。add( 下月 。上月 .addActionListener(
23、this下月 .addActionListener(this 。 showMonth.setText(+month 。public void setMonth(int monthif(month=1this.month=month 。elsethis.month=1 。showMonth.setText(+month 。public int getMonth(return month 。public void actionPerformed(ActionEvent e if(e.getSource(= 上月 if(month=2month=month-1 。日历 .setMonth(month
24、 。日历.设置日历牌 (日历 .getYear(,month else if(month=1month=12 。日历 .setMonth(month 。日历.设置日历牌 (日历 .getYear(,month showMonth.setText(+month 。else if(e.getSource(= 下月 if(monthmonth=month+1 。日历 .setMonth(month 。日历.设置日历牌 (日历 .getYear(,month 。else if(month=12month=1 。日历 .setMonth(month 。 日历.设置日历牌 (日历 .getYear(,mo
25、nth 。 showMonth.setText(+month 。4. 日历记事本系统记事本模块 (NotePad.java 该模块中包含的主要成员变量有文本框 (JTextArea, 按钮 (JButton 保存 日志 删除日志 ,用于存放日志记录的文件 (File 以及响应相关操作的信息提示 (JLabel该模块中包含的主要方法有设置信息条 ,设置文本区 ,获取日志内容 ,保存 日志,删除日志实现编码如下 :import java.awt.* 。import java.awt.event.* 。import java.util.* 。import javax.swing.* 。import
26、javax.swing.event.* 。import java.io.* 。public class NotePad extends JPanel implements ActionListenerJTextArea text 。JButton 保存日志 ,删除日志。Hashtable table 。JLabel 信息条。int year,month,day 。File file 。CalendarPad calendar 。public NotePad(CalendarPad calendarthis.calendar=calendar 。 year=calendar.getYear( 。
27、 month=calendar.getMonth( 。 day=calendar.getDay( 。 table=calendar.getHashtable( 。 file=calendar.getFile( 。信息条=new JLabel(+year+年+month+月+day+日,JLabel.CENTER 。信息条 .setFont(new Font(TimesRoman,Font.BOLD,16 信息条 .setForeground(Color.blue 。text=new JTextArea(10,10 。保存日志 =new JButton( 保存日志 。 删除日志 =new JBu
28、tton( 删除日志 。 保存日志 .addActionListener(this 。 删除日志 .addActionListener(this 。 setLayout(new BorderLayout( 。 JPanel pSouth=new JPanel( 。 add( 信息条 ,BorderLayout.NORTH 。 pSouth.add( 保存日志 。pSouth.add( 删除日志 。 add(pSouth,BorderLayout.SOUTH 。add(new JScrollPane(text,BorderLayout.CENTER 。public void actionPerf
29、ormed(ActionEvent eif(e.getSource(= 保存日志 保存日志 (year,month,day 。else if(e.getSource(= 删除日志 删除日志 (year,month,day 。public void setYear(int yearthis.year=year 。public int getYear(return year 。public void setMonth(int monththis.month=month 。public int getMonth(return month 。public void setDay(int daythis
30、.day=day 。public int getDay(return day 。public void 设置信息条 (int year,int month,int day信息条.setText(+year+年+month+月+day+日。public void 设置文本区 (String stext.setText(s 。public void 获取日志内容 (int year,int month,int dayString key=+year+month+day 。 tryFileInputStream inOne=new FileInputStream(file 。 ObjectInput
31、Stream inTwo=newObjectInputStream(inOne 。 table=(HashtableinTwo.readObject( 。 inOne.close( 。 inTwo.close( 。 catch(Exception ee if(table.containsKey(keyString m=+yea叶年+month+月+day+这一天有日志 记载 ,是否查看 ?。int ok=JOptionPane.showConfirmDialog(this,m, 询问,JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE
32、 。 if(ok=JOptionPane.YES_OPTIONtext.setText(Stringtable.get(key 。 elsetext.setText( 。elsetext.setText( 无记录 。public void 保存日志 (int year,int month,int dayString 日志内容 =text.getText( 。String key=+year+month+day 。String m=+year+年+month+月+day+保存日志吗?。 int ok=JOptionPane.showConfirmDialog(this,m, 询问 ,JOptio
33、nPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE if(ok=JOptionPane.YES_OPTIONtryFileInputStream inOne=new FileInputStream(file 。ObjectInputStream inTwo=new ObjectInputStream(inOne 。table=(HashtableinTwo.readObject( 。 inOne.close( 。inTwo.close( 。 table.put(key, 日志内容 。FileOutputStream out=newFileOutpu
34、tStream(file 。ObjectOutputStream objectOut=new ObjectOutputStream(out 。objectOut.writeObject(table 。 objectOut.close( 。out.close( 。catch(Exception eepublic void 删除日志 (int year,int month,int dayString key=+year+month+day 。if(table.containsKey(keyString m=删除+year+年+month+月+day+日的日志 吗?。int ok=JOptionPane.showConfirmDialog(this,m, 询问 ,JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE 。if(ok=JOptionPane.YES_OPT
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年03月国家药品监督管理局直属单位公开招聘126人笔试历年典型考题(历年真题考点)解题思路附带答案详解
- 武汉工程科技学院《篆刻1》2023-2024学年第二学期期末试卷
- 井下多功能测振仪项目安全评估报告
- 福建对外经济贸易职业技术学院《图片摄影》2023-2024学年第二学期期末试卷
- 山东艺术设计职业学院《西方戏剧选读》2023-2024学年第二学期期末试卷
- 濮阳职业技术学院《色彩静物及人物头像》2023-2024学年第二学期期末试卷
- 年3D打印耗材项目安全评估报告
- 石家庄幼儿师范高等专科学校《美学与美育》2023-2024学年第一学期期末试卷
- 四川汽车职业技术学院《投资学》2023-2024学年第二学期期末试卷
- 河北政法职业学院《小学英语教学设计》2023-2024学年第二学期期末试卷
- 二零二四年度美团共享单车服务协议
- 《农村普惠金融发展研究的国内外文献综述》4500字
- 渔光互补光伏发电项目反事故及预防措施
- 农业昆虫学-形考测试四-国开(ZJ)-参考资料
- 中式烹调师理论知识测试题与参考答案
- 家园的治理:环境科学概论学习通超星期末考试答案章节答案2024年
- 2022年高中学业水平考试政治历史地理试题及答案
- 人工肩关节置换(反肩)
- 2024年执业助理医师实践技能考试体格检查
- 2020年全国硕士研究生招生考试《思想政治理论》真题及解析
- 部编人教版五年级下册语文1-8单元作文课件
评论
0/150
提交评论