Java编写 万年历Word格式文档下载.docx
- 文档编号:16082196
- 上传时间:2022-11-18
- 格式:DOCX
- 页数:12
- 大小:154.40KB
Java编写 万年历Word格式文档下载.docx
《Java编写 万年历Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《Java编写 万年历Word格式文档下载.docx(12页珍藏版)》请在冰豆网上搜索。
(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;
importclassYearextendsBoximplementsActionListener;
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);
}catch(Exceptione){
}
publicvoidquery(Stringsql){
rs=(sql);
publicbooleannext(){
if())b=true;
publicStringgetValue(Stringfield){
Stringvalue="
"
if(rs!
=null)value=(field);
();
if(value==null)value="
returnvalue;
publicvoidcloseConn(){
if(conn!
=null)
();
publicvoidcloseStm(){
if(stm!
publicvoidcloseRs(){
if(rs!
publicConnectiongetConn(){
returnconn;
publicvoidsetConn(Connectionconn){
=conn;
publicResultSetgetRs(){
returnrs;
publicvoidsetRs(ResultSetrs){
=rs;
publicStatementgetStm(){
returnstm;
publicvoidsetStm(Statementstm){
=stm;
}
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;
w_num+month_num;
showDay[i].setText("
+n);
if(n==day)
showDay[i].setForeground;
showDay[i].setFont(newFont("
TimesRoman"
,20));
,12));
showDay[i].setForeground;
if(i%7==6)
if(i%7==0)
n++;
w_num;
for(inti=w_num+month_num;
publicintgetYear()
returnyear;
publicvoidsetYear(inty)
year=y;
(year);
publicintgetMonth()
returnmonth;
public
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java编写 万年历 Java 编写
![提示](https://static.bdocx.com/images/bang_tan.gif)