教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 建筑文档 >

JAVA《万年历系统》课程设计报告附源码(2)

来源:网络收集 时间:2026-02-06
导读: return panel; label = new JLabel(columnNames[i], JLabel.CENTER); if (i == 0 || i == 6) label.setForeground(Color.RED); label.setBorder(new LineBorder(new Color(70, 130, 180))); panel.add(label); priv

return panel;

label = new JLabel(columnNames[i], JLabel.CENTER); if (i == 0 || i == 6)

label.setForeground(Color.RED);

label.setBorder(new LineBorder(new Color(70, 130, 180))); panel.add(label);

private JPanel initializtion_Calendar() {// 显示日期的panel }

JPanel panel = new JPanel();

panel.setLayout(new GridLayout(6, 7)); for (int i = 0; i < 6; i++) { }

return panel;

for (int j = 0; j < 7; j++) { }

label = new JLabel(\datas[i][j] = label;

label.setBorder(new LineBorder(new Color(70, 130, 180))); if (j == 0 || j == 6)

label.setForeground(Color.RED);

datas[i][j].addMouseListener(new List_MouseListener()); panel.add(label);

public void clear_Data() {// 清空内容的

for (int i = 0; i < 6; i++)

for (int j = 0; j < 7; j++) {

datas[i][j].setText(\

20

计算机与信息工程系 《面向对象程序设计》课程设计报告

}

}

if (j == 0 || j == 6)

datas[i][j].setForeground(Color.RED); else

datas[i][j].setForeground(null);

public void initializtion_Data(Calendar calendar) {// 初始化函数

// ////////////////////////////////////////////////// // ////////////////////////////////////////////////////////// /*

* 节日和纪念日 格式:起始年(yyyy)+月(mm)+日(dd) * * *

* 0000表示起始年不明 */

HashMap sFestival = new HashMap(); // String []sFestival_={ sFestival.put(\ 元旦\sFestival.put(\情人节\sFestival.put(\妇女节\sFestival.put(\植树节\sFestival.put(\愚人节\sFestival.put(\劳动节\sFestival.put(\青年节\sFestival.put(\儿童节\sFestival.put(\建党节\sFestival.put(\建军节\

21

计算机与信息工程系 《面向对象程序设计》课程设计报告

sFestival.put(\教师节\sFestival.put(\国庆节\sFestival.put(\万圣节\sFestival.put(\孙中山诞辰\sFestival.put(\圣诞节\sFestival.put(\毛泽东诞辰\// };

// 某月第几个星期几

// 起始年(4位)+月(2位)+第几个(1位)+星期几(1位)

HashMap wFestival = new HashMap(); // String []wFestival={

wFestival.put(\母亲节\wFestival.put(\父亲节\wFestival.put(\感恩节\// };

// 农历 99表示月最后一天

HashMap lFestival = new HashMap(); // String []lFestival={ lFestival.put(\春 节\lFestival.put(\大年初二\lFestival.put(\大年初三\lFestival.put(\元宵节\lFestival.put(\端午节\lFestival.put(\七 夕\lFestival.put(\中秋节\lFestival.put(\重阳节\lFestival.put(\腊八节\lFestival.put(\除 夕\// };

// ///////////////////////////////////////////////////////////

22

计算机与信息工程系 《面向对象程序设计》课程设计报告

// ////////////////////////////////////////////////// this.calendar = calendar;

today = calendar.get(Calendar.DAY_OF_MONTH); int month = calendar.get(Calendar.MONTH); int weekindexDay; int weekindexMonth;

calendar.set(Calendar.DATE, 1);

while (calendar.get(Calendar.MONTH) == month) {

weekindexMonth = calendar.get(Calendar.WEEK_OF_MONTH) - 1; weekindexDay = calendar.get(Calendar.DAY_OF_WEEK) - 1; int day = calendar.get(Calendar.DAY_OF_MONTH); // ///////////////////////////////////////////// String today_, month_;

today_ = day < 10 ? \

month_ = month < 10 ? \Lunar lunar = new Lunar(calendar); String lunar_ = lunar.toString(); // /////////////////////////////////////////

if (null != sFestival.get(month_ + today_))

lunar_ = \

// /////

String wFestival_ = month_ + (weekindexMonth) + (weekindexDay);

if (null != wFestival.get(wFestival_)) { }

if (null != lFestival.get(lunar.numeric_md()))

lunar_ = \//System.out.println(wFestival_);

lunar_ = \

23

计算机与信息工程系 《面向对象程序设计》课程设计报告

// 计算除夕

Calendar temp_calendar = Calendar.getInstance();

temp_calendar.set(calendar.get(Calendar.YEAR), month, day + 1); // temp_calendar.add(Calendar.DAY_OF_MONTH,1); Lunar temp_lunar = new Lunar(temp_calendar); String temp_str = temp_lunar.numeric_md(); if (temp_str.equals(\

lunar_ = \

// /计算除夕结束

// //////////////////////////////////////// String day_str; if (day < 10)

day_str = \

else

day_str = \

day_str += \if (day == today)

datas[weekindexMonth][weekindexDay].setForeground(Color.GREEN); }

public void actionPerformed(ActionEvent e) {// 日期和年份的选择更新 int year = Integer.parseInt(year_box.getSelectedItem().toString()); int month = Integer.parseInt(month_box.getSelectedItem().toString()) - 1;

}

// ///////////////////////////////////////////////

datas[weekindexMonth][weekindexDay].setText(day_str); calendar.add(Calendar.DATE, 1);

calendar.set(year, month, today);

clear_Data();

Initializtion_Data(calendar);

24

计算机与信息工程系 《面向对象程序设计》课程设计报告

}

class List_MouseListener implements MouseListener {// 鼠标移入时显示的信

JLabel labe = null;

String weeks[] = { \星期日\星期一\星期二\星期三\星期四\星

期五\星期六\

public String constellation(Calendar cal) {

String[][] con = { { \水瓶座\

{ \双鱼座\白羊座\{ \金牛座\双子座\{ \巨蟹座\狮子座\{ \处女座\天秤座\{ \天蝎座\射手座\{ \摩羯座\

int month = cal.get(Calendar.MONTH) + 1; int today = cal.get(Calendar.DAY_O …… 此处隐藏:5221字,全部文档内容请下载后查看。喜欢就下载吧 ……

JAVA《万年历系统》课程设计报告附源码(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/682541.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)