用java编辑日历记事本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用java编辑日历记事本相关的知识,希望对你有一定的参考价值。
1、 内容
设计GUI 界面的日历记事本。系统将日历、记事本结合在一起,用户可以方便地在任何日期记载有关内容以及查看某个日期记载的内容。
2、 设计要求
1)界面的左侧是日历。该日历可以按年前后翻动,当鼠标单击“上一年”按钮时,当前日历的年份将减一;当鼠标左键单击“下年”按钮,当前日历的年份将加一。
2)也可以在某年内按月前后翻动。当鼠标左键单击“上月”按钮时,当前日历的月份将减一;当鼠标左键单击“下月” 当前日历表的月份将加一。
3)使用鼠标左键在要选择的日期上单击,如有记事内容,程序将弹出对话框提示该日有记事内容,提示用户是否用记事本显示该内容。
4)选择具体日期后,可以将记事本的内容保存起来,形成一个日志。
<head>
<title>HTML</title>
<style type="text/css">
#calender
width:150;
height:170;
#currentTime
border:1px dotted #999999;
width:80px;
text-align:center;
button
border:1px solid #7baddd;
font:9pt Verdana,"宋体";
cursor: pointer;
table
width:280px;
text-align:center;
</style>
<script type="text/javascript">
var daysOfMonth = new Array();
daysOfMonth[0] = 31;
daysOfMonth[1] = 28;
daysOfMonth[2] = 31;
daysOfMonth[3] = 30;
daysOfMonth[4] = 31;
daysOfMonth[5] = 30;
daysOfMonth[6] = 31;
daysOfMonth[7] = 31;
daysOfMonth[8] = 30;
daysOfMonth[9] = 31;
daysOfMonth[10] = 30;
daysOfMonth[11] = 31;
var monthchange=0;
var nowTime = new Date();
var nowYear =nowTime.getFullYear();
var nowMonth =nowTime.getMonth();
var nowDate =nowTime.getDate();
function genernate(year,month)
if(year==null||month==null)
year = nowYear;
month = nowMonth;
nowTime.setFullYear(year,month,1); if((nowYear%400==0)||((nowYear%4==0)&&((nowYear%100)!=0)))
daysOfMonth[1]=29;
else
daysOfMonth[1]=28;
var firstDay = nowTime.getDay();
var day = 1;
var result = "<table>";
result+="<thead><tr><th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr></thead>";
result+="<tbody>";
for(var i=0;i<6;i++)
result+="<tr>";
if(i!=0) firstDay=-1;
for(var j=0;j<7&&day<= daysOfMonth[month];j++)
if(j<firstDay)
result+="<td> </td>";
else
if((day==nowDate)&&(monthchange==0))
result+="<td><span style=\"color:red;border:1px dotted #666666\">"+day+"</span></td>";
else
result+="<td>"+day+"</td>";
day++;
result+="<tr>";
result+="</tbody>";
result+="</table>"; document.getElementById("calender").innerHTML = result;
setContent();
function preyear()
monthchange-=12;
genernate(--nowYear,nowMonth);
function nextyear()
monthchange+=12;
genernate(++nowYear,nowMonth);
function premonth()
--monthchange;
if(nowMonth==0)
nowMonth=11;
nowYear-=1;
else
nowMonth-=1;
genernate(nowYear,nowMonth);
function nextmonth()
++monthchange;
if(nowMonth==11)
nowMonth=0;
nowYear+=1;
else
nowMonth+=1;
genernate(nowYear,nowMonth);
function setContent()
document.getElementById("contentYear").innerHTML = nowYear;
document.getElementById("contentMonth").innerHTML = nowMonth+1;
function getCurrentTime()
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
var second = time.getSeconds();
if((hours==0)&&(minutes==0)&&(second==0))
nowDate = time.getDate();
genernate(time.getFullYear(),time.getMonth());
document.getElementById("currentTime").innerHTML = time.toLocaleTimeString();
setTimeout("getCurrentTime()",500);
function currentDate()
var todayTime = new Date();
var todayYear =todayTime.getFullYear();
var todayMonth =todayTime.getMonth();
nowDate = todayTime.getDate();
monthchange=0;
nowYear = todayYear;
nowMonth = todayMonth;
genernate(todayYear,todayMonth);
</script>
</head>
<body onload="genernate();getCurrentTime();">
<h2>自己做的小日历</h2>
<div>
<div><span><span id="contentYear"></span> 年 <span id="contentMonth"></span> 月</span></div>
<div><button onclick="preyear();">上一年</button><button onclick="nextyear();">下一年</button><button onclick="premonth();">上一月</button><button onclick="nextmonth();">下一月</button><button onclick="currentDate();">回到今天</button></div>
<div id="calender"></div>
</div>
<h3>当前时间</h3>
<div id="currentTime"><div>
</body>
</html>本回答被提问者采纳 参考技术B 好简单啊,我有一个html的日历- -。就差一个文本框记录内容了- -|||。
以上是关于用java编辑日历记事本的主要内容,如果未能解决你的问题,请参考以下文章