资源简介
java设计的时钟日历

代码片段和文件信息
package clockWithCalender;
import java.awt.*;
import java.awt.event.*;
import java.util.Calendar;
import javax.swing.*;
class CalendarCal {
String day[];
int year month;
public void setYear(int year) {
this.year = year;
}
public int getYear() {
return year;
}
public void setMonth(int month) {
this.month = month;
}
public int getMonth() {
return month;
}
public String[] getCalendar() {
String day_of_week[] = new String[42];
Calendar c = Calendar.getInstance();
c.set(year month - 1 1);
int weekday = c.get(Calendar.DAY_OF_WEEK) - 1;
int day = 0;
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
day = 31;
}
if (month == 4 || month == 6 || month == 9 || month == 11) {
day = 30;
}
if (month == 2) {
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
day = 29;
} else {
day = 28;
}
}
for (int i = weekday n = 1; i < weekday + day; i++) {
day_of_week[i] = String.valueOf(n);
n++;
}
return day_of_week;
}
}
public class CalendarPanel extends JPanel implements ActionListener {
Calendar c=Calendar.getInstance();
Label labelDay[] = new Label[42];
Label titleName[] = new Label[7];
String name[] = { “日“ “一“ “二“ “三“ “四“ “五“ “六“ };
String day_of_week;
JButton previousMonthnextMonth;
int year = c.get(Calendar.YEAR) month = c.get(Calendar.MONTH)+1
date=c.get(Calendar.DATE)WeekDay=c.get(Calendar.DAY_OF_WEEK)-1;
CalendarCal calendar;
Label showMessage = new Label(““ Label.CENTER);
Label showdate=new Label(““);
public CalendarPanel() {
Panel pCenter = new Panel();
Panel pNorth = new Panel();
Panel pSouth = new Panel();
pCenter.setLayout(new GridLayout(7 7));
for(int i = 0; i < 7; i++)
{
if(i==WeekDay)
day_of_week=name[i];
}
showdate.setText(String.valueOf(year)+“年“+String.valueOf(month)+“月“+String.valueOf(date)+“日“
+“ 星期“+day_of_week);
showdate.setFont(new Font(“Tahoma“ Font.PLAIN30));
for (int i = 0; i < 7; i++) {
titleName[i] = new Label(name[i]Label.CENTER);
titleName[i].setFont(new Font(“Tahoma“ Font.PLAIN50));
pCenter.add(titleName[i]);
}
for (int i = 0; i < 42; i++) {
labelDay[i] = new Label(““ Label.CENTER);
labelDay[i].setFont(new Font(“Tahoma“ Font.PLAIN30));
pCenter.add(labelDay[i]);
}
calendar = new CalendarCal();
calendar.setYear(year);
calendar.setMonth(month);
String day[] = calendar.getCalendar();
for (int i = 0; i < 42; i++) {
labelDay[i].setText(day[i]);
if(String.valueOf(c.get(Calendar.DATE)).equals(day[i]))
labelDay[i].setBackground(Color.blue);;
}
nextMonth = new JButton(new ImageIcon(“image\\you.JPG“));
previousMonth = new JButton(new ImageIcon(“image\\zuo.JPG“));
nextMonth.addActionListener(this);
previousMonth.addActionList
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-06-18 18:52 时钟日历\
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
文件 1027612 2016-05-31 20:03 时钟日历\Eclipse工程\.me
文件 0 2016-03-16 12:21 时钟日历\Eclipse工程\.me
文件 105133 2016-06-18 09:32 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
文件 20 2016-03-16 12:22 时钟日历\Eclipse工程\.me
文件 32 2016-03-16 12:22 时钟日历\Eclipse工程\.me
文件 250 2016-04-21 16:33 时钟日历\Eclipse工程\.me
目录 0 2016-03-16 12:21 时钟日历\Eclipse工程\.me
文件 438 2016-03-16 12:22 时钟日历\Eclipse工程\.me
文件 250 2016-04-24 11:28 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
文件 411 2016-06-16 20:01 时钟日历\Eclipse工程\.me
文件 4187 2016-06-12 16:14 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
目录 0 2016-06-13 00:59 时钟日历\Eclipse工程\.me
目录 0 2016-06-16 23:53 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
文件 2690 2016-06-12 23:55 时钟日历\Eclipse工程\.me
文件 2435 2016-06-12 23:19 时钟日历\Eclipse工程\.me
文件 2697 2016-06-13 00:48 时钟日历\Eclipse工程\.me
目录 0 2016-06-04 16:33 时钟日历\Eclipse工程\.me
目录 0 2016-06-12 00:17 时钟日历\Eclipse工程\.me
目录 0 2016-06-11 00:19 时钟日历\Eclipse工程\.me
目录 0 2016-06-18 11:15 时钟日历\Eclipse工程\.me
............此处省略858个文件信息
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
评论
共有 条评论