Java编写 万年历

上传人:tang****xu1 文档编号:132723718 上传时间:2020-05-19 格式:DOC 页数:20 大小:215.50KB
返回 下载 相关 举报
Java编写 万年历_第1页
第1页 / 共20页
Java编写 万年历_第2页
第2页 / 共20页
Java编写 万年历_第3页
第3页 / 共20页
Java编写 万年历_第4页
第4页 / 共20页
Java编写 万年历_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《Java编写 万年历》由会员分享,可在线阅读,更多相关《Java编写 万年历(20页珍藏版)》请在金锄头文库上搜索。

1、20陕西师范大学远程教育学院考查课科目java程序设计姓 名霍娟学 号61861610310002专 业计算机科学与技术批 次 161层 次专升本学习中心铜川职业技术学院Java万年历一 项目概述:这个项目是一个简单的Java万年历,可以实现所有年份的公历日期的查询,并且在相应的日期做备忘录,以及可以显示当前的日期以及时间。使用的是Oracle数据库进行连接。二 具体功能介绍:(1)万年历查询:点击图形界面中的上年、下年键用来调整要查询的年份,或者可以直接在上年下年按钮直接的文本框中输入年份(负数表示公元前),以回车结束;点击上月或者下月来调整要查询的月份,然后可以看到这个月的每一天所对应的星

2、期。(2)Clock功能:在万年历下面显示当前的年月日时分秒,相当于一个时钟的功能。(3)记事本功能:可以任选某年某月的某一天,单击,在右侧会出现这一天的备忘录,如果存在,则显示某年某月某日有日志记载,是否想看,否则,则在文本框中显示无记录;然后可以编辑这一天的备忘录,编辑好了之后,点击保存日志,弹出对话框某年某月某日保存日志吗,点击保存,则日志被保存,反之未被保存;若想删除某日的日志,则单击这一天,然后点击右侧的删除日志,显示删除某年某月某日的日志吗,点击是,则日志被删除。从文件中读取备忘录的内容,用数据库进行存储和删除操作。三设计与实现(需要附全部代码,GUI自动生成代码除外):1 类的设

3、计(继承、多态、数据结构):核心类是Month,Year,NotePad,Clock,DBAccess,CalendarPad.(其中继承用粗体,接口用粗斜体,数据结构是哈希表,用粗下划线,多态用斜体+点点短线式下划线)2 Java IO (文件访问):用的是粗体+浪线3 JDBC (数据库访问):使用Oracle数据库连接,是直连(双下划线)数据库是:create table mynotes( mydate varchar2(50) primary key, note varchar2(100) not null);4 Socket + Multi-Thread:斜体(定义在Clock中的T

4、hread t)5 GUI (用户界面):点下划线来表示GUI用户界面6 其他功能:(无)以下是全部代码(共六个.Java文件)/对月份的选择package javaapplication13;import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Monthextends Boximplements ActionListener/ActionListener接口 int month;JTextField showMonth=null;JButton RMonth,NMonth; CalendarP

5、ad cal; public Month(CalendarPad c) super(BoxLayout.X_AXIS); this.cal=c; showMonth=new JTextField(2); month=c.getMonth(); showMonth.setEditable(false);showMonth.setForeground(Color.blue);showMonth.setFont(new Font(TimesRomn,Font.BOLD,16);NMonth=new JButton(下月);RMonth=new JButton(上月); add(RMonth); ad

6、d(showMonth); add(NMonth); RMonth.addActionListener(this); NMonth.addActionListener(this); showMonth.setText(+month); public void setMonth(int month) if(month=1) this.month=month; else this.month=1; showMonth.setText(+month); public int getMonth() return month; public void actionPerformed(ActionEven

7、t e) if(e.getSource()=RMonth) if(month=2) month=month-1; cal.setMonth(month); cal.setCal(cal.getYear(),month); else if(month=1) month=12; cal.setMonth(month); cal.setCal(cal.getYear(),month); showMonth.setText(+month); else if(e.getSource()=NMonth) if(month12) month=month+1; cal.setMonth(month); cal

8、.setCal(cal.getYear(),month); else if(month=12) month=1; cal.setMonth(month); cal.setCal(cal.getYear(),month); showMonth.setText(+month); /对年分的选择package javaapplication13;import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Yearextends Box implements ActionListener/ActionListe

9、ner接口 int year;JTextField showYear=null;JButton NYear,RYear; CalendarPad cal; public Year(CalendarPad c) super(BoxLayout.X_AXIS);showYear=new JTextField(4);showYear.setForeground(Color.blue);showYear.setFont(new Font(TimesRomn,Font.BOLD,14); this.cal=c; year=cal.getYear();NYear=new JButton(下年);RYear

10、=new JButton(上年); add(RYear); add(showYear); add(NYear); showYear.addActionListener(this); RYear.addActionListener(this); NYear.addActionListener(this); public void setYear(int year) this.year=year; showYear.setText(+year); public int getYear() return year; public void actionPerformed(ActionEvent e)

11、 if(e.getSource()=RYear) year=year-1; showYear.setText(+year); cal.setYear(year); cal.setCal(year,cal.getMonth(); else if(e.getSource()=NYear) year=year+1; showYear.setText(+year); cal.setYear(year); cal.setCal(year,cal.getMonth(); else if(e.getSource()=showYear) try year=Integer.parseInt(showYear.g

12、etText(); showYear.setText(+year); cal.setYear(year); cal.setCal(year,cal.getMonth(); catch(NumberFormatException ee) showYear.setText(+year); cal.setYear(year); cal.setCal(year,cal.getMonth(); /对备忘录的操作package javaapplication13;import java.awt.*;import java.awt.event.*;import java.util.*;import javax.swing.*;import javax.swing.event.*;import java.io.*;public class NotePad extends JPanel implements ActionListenerJTextArea text

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 商业计划书

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号