Java编写 万年历.docx

上传人:b****6 文档编号:3171271 上传时间:2022-11-18 格式:DOCX 页数:12 大小:154.40KB
下载 相关 举报
Java编写 万年历.docx_第1页
第1页 / 共12页
Java编写 万年历.docx_第2页
第2页 / 共12页
Java编写 万年历.docx_第3页
第3页 / 共12页
Java编写 万年历.docx_第4页
第4页 / 共12页
Java编写 万年历.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

Java编写 万年历.docx

《Java编写 万年历.docx》由会员分享,可在线阅读,更多相关《Java编写 万年历.docx(12页珍藏版)》请在冰豆网上搜索。

Java编写 万年历.docx

Java编写万年历

陕西师范大学远程教育学院考查课

科目__java程序设计__

 

姓名____霍娟______

学号___6__

专业__计算机科学与技术__

批次_161______

层次_____专升本____

学习中心__铜川职业技术学院__

Java万年历

一项目概述:

这个项目是一个简单的Java万年历,可以实现所有年份的公历日期的查询,并且在相应的日期做备忘录,以及可以显示当前的日期以及时间。

使用的是Oracle数据库进行连接。

二具体功能介绍:

(1)万年历查询:

点击图形界面中的上年、下年键用来调整要查询的年份,或者可以直接在上年下年按钮直接的文本框中输入年份(负数表示公元前),以回车结束;点击上月或者下月来调整要查询的月份,然后可以看到这个月的每一天所对应的星期。

(2)Clock功能:

在万年历下面显示当前的年月日时分秒,相当于一个时钟的功能。

(3)记事本功能:

可以任选某年某月的某一天,单击,在右侧会出现这一天的备忘录,如果存在,则显示某年某月某日有日志记载,是否想看,否则,则在文本框中显示无记录;然后可以编辑这一天的备忘录,编辑好了之后,点击保存日志,弹出对话框某年某月某日保存日志吗,点击保存,则日志被保存,反之未被保存;若想删除某日的日志,则单击这一天,然后点击右侧的删除日志,显示删除某年某月某日的日志吗,点击是,则日志被删除。

从文件中读取备忘录的内容,用数据库进行存储和删除操作。

三设计与实现(需要附全部代码,GUI自动生成代码除外):

1类的设计(继承、多态、数据结构):

核心类是Month,Year,NotePad,Clock,DBAccess,CalendarPad.(其中继承用粗体,接口用粗斜体,数据结构是哈希表,用粗下划线,多态用斜体+点点短线式下划线)

2JavaIO(文件访问):

用的是粗体+浪线

3JDBC(数据库访问):

使用Oracle数据库连接,是直连(双下划线)

数据库是:

createtablemynotes(

mydatevarchar2(50)primarykey,

notevarchar2(100)notnull

);

4Socket+Multi-Thread:

斜体(定义在Clock中的Threadt)

5GUI(用户界面):

点下划线来表示GUI用户界面

6其他功能:

(无)

以下是全部代码(共六个.Java文件)

;

import.*;

importclassMonthextendsBoximplementsActionListener;

import.*;

importclassYearextendsBoximplementsActionListener;

import.*;

import.*;

import.*;

publicclassNotePadextendsJPanelimplementsActionListener

{

JTextAreatext;

JButtonsave_log,del_log;

Hashtabletable;

JLabelmes_label;

intyear,month,day;

Filefile;

CalendarPadcalendar;

publicNotePad(CalendarPadcalendar)ewInstance();

conn=(url,usr,pwd);

b=true;

}catch(SQLExceptione){

}catch(ClassNotFoundExceptione){

}catch(InstantiationExceptione){

}catch(IllegalAccessExceptione){

}

returnb;

}

publicbooleanupdate(Stringsql){

booleanb=false;

try{

stm=();

(sql);

b=true;

}catch(Exceptione){

}

returnb;

}

publicvoidquery(Stringsql){

try{

stm=();

rs=(sql);

}catch(Exceptione){

}

}

publicbooleannext(){

booleanb=false;

try{

if())b=true;

}catch(Exceptione){

}

returnb;

}

publicStringgetValue(Stringfield){

Stringvalue="";

try{

if(rs!

=null)value=(field);

}catch(Exceptione){

();

}

if(value==null)value="";

returnvalue;

}

publicvoidcloseConn(){

try{

if(conn!

=null)

();

}catch(SQLExceptione){

}

}

publicvoidcloseStm(){

try{

if(stm!

=null)

();

}catch(SQLExceptione){

}

}

publicvoidcloseRs(){

try{

if(rs!

=null)

();

}catch(SQLExceptione){

}

}

publicConnectiongetConn(){

returnconn;

}

publicvoidsetConn(Connectionconn){

=conn;

}

publicResultSetgetRs(){

returnrs;

}

publicvoidsetRs(ResultSetrs){

=rs;

}

publicStatementgetStm(){

returnstm;

}

publicvoidsetStm(Statementstm){

=stm;

}

}

;

import.*;

import.*;etText(w[j]);

title[j].setBorder());

(title[j]);

}

title[0].setForeground;

title[6].setForeground;

for(inti=0;i<42;i++)

{

showDay[i]=newJTextField();

showDay[i].addMouseListener(this);

showDay[i].setEditable(false);

(showDay[i]);

}

cal=();

Boxbox=();

(ChangeYear);

(ChangeMonth);

(box);

(newBorderLayout());

(leftNorth,;

(leftCenter,;

(newLabel("年份框输入年份(负数公元前)回车确定"),

;

(newClock(this),;xt");

if(!

())

{

try{

FileOutputStreamout=newFileOutputStream(file);

ObjectOutputStreamobjectOut=newObjectOutputStream(out);

(hashtable);

();

();

}

catch(IOExceptione)

{

}

}

notepad=newNotePad(this);

(notepad);

setCal(year,month);

addWindowListener(newWindowAdapter()

{publicvoidwindowClosing(WindowEvente)

{

(0);

}

});

setVisible(true);

setBounds(100,50,524,285);

validate();

}

publicvoidsetCal(intyear,intmonth)

{

(year,month-1,1);

week=-1;

if(month==1||month==2||month==3||month==5||month==7

||month==8||month==10||month==12)

{

QueryNum(week,31);

}

elseif(month==4||month==6||month==9||month==11)

{

QueryNum(week,30);

}

elseif(month==2)

{

if((year%4==0&&year%100!

=0)||(year%400==0))

{

QueryNum(week,29);

}

else

{

QueryNum(week,28);

}

}

}

publicvoidQueryNum(intw_num,intmonth_num)

{

for(inti=w_num,n=1;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

{

showDay[i].setText("");

}

for(inti=w_num+month_num;i<42;i++)

{

showDay[i].setText("");

}

}

publicintgetYear()

{

returnyear;

}

publicvoidsetYear(inty)

{

year=y;

(year);

}

publicintgetMonth()

{

returnmonth;

}

public

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1