




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司出售旧车合同范本
- 室内门定制合同范本
- 检疫运输合同范本
- 医院事业编合同范本
- 房屋租赁合同标准版
- 好心情我做主心理健康教育
- 静脉输血相关制度及流程
- 湖南高尔夫旅游职业学院《生物医学产品标准及生产法规》2023-2024学年第二学期期末试卷
- 河南工业贸易职业学院《试验设计与统计理论基础》2023-2024学年第二学期期末试卷
- 2025年安徽省黄山市高三阶段性测试(五)数学试题含解析
- 公安机关处置群体性治安事件规定
- 江苏省2024年中职职教高考文化统考英语试卷
- 室外燃气管道安装施工方案
- 2024公司向股东短期借款合同
- 《陆上风电场工程概算定额》NBT 31010-2019
- 2024年江苏省苏州市常熟市、昆山市、太仓市、张家港市等九年级(下)中考一模英语试卷(含解析)
- 新能源汽车构造(中)
- TB 10752-2018 高速铁路桥涵工程施工质量验收标准
- 外卖员交通安全知识讲座
- DB11T 489-2024 建筑基坑支护技术规程
- 危险源辨识专项培训考试试题
评论
0/150
提交评论