版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、师大学远程教育学院考查课科目 java 程序设计 姓名 霍娟 学号 002专业 计算机科学与技术 批次 161层次 专升本 学习中心 职业技术学院 Java 万年 历项目概述 :这个项目是一个简单的 Java 万年历,可以实现所有年份的公历日期的查询,并且在相应的日期做备忘录,以及可以显示当前的日期以及时间。使用的是 Oracle 数据库进行连接。二 具体功能介绍 : (1)万年历查询:点击图形界面中的上年、下年键用来调整要查询的年份,或 者可以直接在上年下年按钮直接的文本框中输入年份(负数表示公元前) ,以回 车结束;点击上月或者下月来调整要查询的月份, 然后可以看到这个月的每一天 所对应的
2、星期。( 2) Clock 功能:在万年历下面显示当前的年月日时分秒,相当于一个时钟的 功能。(3)记事本功能:可以任选某年某月的某一天,单击,在右侧会出现这一天的 备忘录,如果存在,则显示某年某月某日有日志记载,是否想看,否则,则在文 本框中显示无记录; 然后可以编辑这一天的备忘录, 编辑好了之后, 点击保存日 志,弹出对话框某年某月某日保存日志吗,点击保存,则日志被保存,反之未被 保存;若想删除某日的日志,则单击这一天,然后点击右侧的删除日志,显示删 除某年某月某日的日志吗,点击是,则日志被删除。从文件中读取备忘录的容, 用数据库进行存储和删除操作。三 设计与实现 (需要附全部代码, GU
3、I 自动生成代码除外) :1 类 的 设 计 ( 继 承 、 多 态 、 数 据 结 构 ) : 核 心 类 是 Month,Year,NotePad,Clock,DBAccess,CalendarPad(. 其中继承用粗体,接口用粗 斜体,数据结构是哈希表,用粗下划线,多态用斜体 +点点短线式下划线) 2 Java IO (文件访问):用的是粗体 + 浪线3 JDBC (数据库访问):使用 Oracle 数据库连接,是直连(双下划线) 数据库是: create table mynotes(mydate varchar2(50) primary key,note varchar2(100) n
4、ot null);4 Socket + Multi-Thread:斜体(定义在 Clock 中的 Thread t)5 GUI (用户界面):点下划线来表示 GUI 用户界面6 其他功能:(无)以下是全部代码(共六个.Java 文件)/对月份的选择package javaapplication13;import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Month extends Box implements ActionListener/ ActionListener 接口int month;JT
5、extField showMonth=null;JButton RMonth,NMonth;CalendarPad 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 J
6、Button(下月 );RMonth=new JButton(上月 );add(RMonth);add(showMonth);add(NMonth);RMonth.addActionListener(this);NMonth.addActionListener(this); showMonth.setText(+month);public void setMonth(int month)if(month=1)this.month=month;elsethis.month=1;showMonth.setText(+month);public int getMonth()return month;
7、public void actionPerformed(ActionEvent 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(month|oed李重賈田H Je
8、puaieg/:ius = iuss!屮 (ius luoiuoeislwises piOA siqndl.ius ujn;8j ()iuisg6 luoiuowis Siqnd!sj = sjsiqi (sj esilns8)sji8s piOA siqnd!sj ujn;8j Osygb esiinsoy ojiqnd !uuoo = uuoosiqi (uuoo uo!p8uuoo)uuo9i8S piOA siqnd!uuoo ujn;8j ()uuooi86 uoipauuoo siqnd (e uoiid8OX3-|Os) qoeo !()8S0|0SJ (linu =i sj)
9、jiint year,month,day; Hashtable hashtable;File file;JTextField showDay;JLabel title;JLabel label = new JLabel49;JLabel y_label = new JLabel(年份 );JLabel m_label = new JLabel(月份 );Calendar cal;Calendar now = Calendar.getInstance(); /实 例化 Calendar int week;NotePad notepad=null;Month ChangeMonth;Year Ch
10、angeYear;String w= 星期日 ,星期一 ,星期二 ,星期三,星期四,星期五,星期六 ;JPanel leftPanel,rightPanel;public CalendarPad(int year,int month,int day)/构/ 造函数leftPanel=new JPanel();JPanel leftCenter=new JPanel();JPanel leftNorth=new JPanel(); leftCenter.setLayout(new GridLayout(7,7);rightPanel=new JPanel();this.year=year;thi
11、s.month=month; this.day=day;ChangeYear=new Year(this);ChangeYear.setYear(year); ChangeMonth=new Month(this); ChangeMonth.setMonth(month);title=new JLabel7;showDay=new JTextField42;for(int j=0;j7;j+)titlej=new JLabel();titlej.setText(wj);titlej.setBorder(BorderFactory.createRaisedBevelBorder(); leftC
12、enter.add(titlej);title0.setForeground(Color.red); title6.setForeground(Color.blue);for(int i=0;i42;i+) showDayi=new JTextField(); showDayi.addMouseListener(this); showDayi.setEditable(false); leftCenter.add(showDayi);cal=Calendar.getInstance();Box box=Box.createHorizontalBox(); box.add(ChangeYear);
13、 box.add(ChangeMonth); leftNorth.add(box);leftPanel.setLayout(new BorderLayout(); leftPanel.add(leftNorth,BorderLayout.NORTH); leftPanel.add(leftCenter,BorderLayout.CENTER);rightPanel.add(new Label(年份框输入年份 (负数公元前 ) 回车确定 ), BorderLayout.SOUTH) ;leftPanel.add(new Clock(this),BorderLayout.SOUTH); /调用 C
14、lock 类实 例,来实现对当前时间的显示leftPanel.validate();Container con=getContentPane();JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel,rightPanel);con.add(split,BorderLayout.CENTER);con.validate();hashtable=new Hashtable();file=new File( 日历记事本 .txt);if(!file.exists()tryFileOutputStream out=
15、new FileOutputStream(file); ObjectOutputStream objectOut=new ObjectOutputStream(out); objectOut.writeObject(hashtable);objectOut.close(); out.close(); catch(IOException e)notepad=new NotePad(this);rightPanel.add(notepad);setCal(year,month); addWindowListener(new WindowAdapter() public void windowClo
16、sing(WindowEvent e)System.exit(0););setVisible(true);setBounds(100,50,524,285);validate();public void setCal(int year,int month)cal.set(year,month-1,1);week=cal.get(Calendar.DAY_OF_WEEK)-1;if(month=1|month=2|month=3|month=5|month=7 |month=8|month=10|month=12) QueryNum(week,31);else if(month=4|month=
17、6|month=9|month=11)QueryNum(week,30);else if(month=2) if(year%4=0&year%100!=0)|(year%400=0) QueryNum(week,29);elseQueryNum(week,28);public void QueryNum(int w_num,int month_num)for(int i=w_num,n=1;iw_num+month_num;i+) showDayi.setText(+n); if(n=day) showDayi.setForeground(Color.green); showDayi.setF
18、ont(new Font(TimesRoman,Font.BOLD,20);elseshowDayi.setFont(newFont(TimesRoman,Font.BOLD,12); showDayi.setForeground(Color.black);if(i%7=6)showDayi.setForeground(Color.blue);if(i%7=0) showDayi.setForeground(Color.red);n+;for(int i=0;iw_num;i+)showDayi.setText();for(int i=w_num+month_num;i42;i+) showD
19、ayi.setText();public int getYear()return year;public void 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()return file;public void mousePressed(MouseEvent e)JTextField source=(JTextField)e.getSource(); tryday=Integer.parseInt(source.getText(); notepad.setDay(day);notepad.setMesLabel(year,month,day);notepad.setText(null); notepad.get
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 深度解析(2026)《GBT 328.23-2007建筑防水卷材试验方法 第23部分:高分子防水卷材 接缝剪切性能》
- 酒精原料粉碎工冲突解决评优考核试卷含答案
- 信息通信网络线务员风险评估与管理考核试卷含答案
- 烧结成品工安全生产意识模拟考核试卷含答案
- 化工造粒工安全知识宣贯测试考核试卷含答案
- 蒸煮熏烤制品加工工安全知识宣贯水平考核试卷含答案
- 巧克力原料处理工安全技能测试模拟考核试卷含答案
- 己二酸他雷替尼临床应用考核试题
- 麻纺生产车间清洁规程
- 沈阳市政府数据开放:问题剖析与对策探寻
- 2026云南省投资控股集团有限公司招聘168人笔试历年参考题库附带答案详解
- 2026年中医骨伤科(正-副高)试题(得分题)附答案详解(完整版)
- (2025年)电工三级安全教育试题及答案
- 2026年设备状态监测的标准与规范
- 2026广东东莞市常平镇编外聘用人员招聘5人备考题库附答案详解(完整版)
- 高中主题班会 高二上学期《学会专注、高效学习》主题班会课件
- 2026春夏·淘宝天猫运动户外鞋服趋势白皮书
- 《陆上风电场工程概算定额》NBT 31010-2019
- 《联合国海洋法公约》(中文完整)
- GB/T 3840-1991制定地方大气污染物排放标准的技术方法
- GB/T 307.2-2005滚动轴承测量和检验的原则及方法
评论
0/150
提交评论