資源簡介
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? ??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個文件信息
評論
共有 條評論