万年历程序(全版)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
}
this.setResizable(false);
getSysNowTimeInfo();
setNowDate();
setNowDate();
}
public void setSysDate(int year, int month) {
// 将日期设置为year年month月1日
gregorianCalendar.set(year, month, 1);
comboYear.setForeground(new Color(0, 0, 255));
comboYear.setFont(new Font("", Font.PLAIN, 14));
for (int y = 1900; y < 2101; y++) {
comboYear.addItem(" " + new Integer(y).toString());
private JButton buttonNextMonth = new JButton();
private JComboBox comboYear = new JComboBox();
private JComboBox comboMonth = new JComboBox();
public Calender2() {
private String[] strSysTime = new String[6];
// 存ຫໍສະໝຸດ Baidu当前日期信息
private String[] strSysNowTime = new String[6];
// 存储运行时日期信息
private JButton[] buttonDay = new JButton[42];
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
private Date date = new Date();
private GregorianCalendar gregorianCalendar = new GregorianCalendar();
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Calender2 extends JFrame implements ActionListener, ItemListener {
getContentPane().add(buttonToday);
buttonToday.setForeground(Color.BLUE);
buttonToday.setFont(new Font("新宋体", Font.PLAIN, 14));
buttonToday.setText("今天");
"星期四", "星期五", "星期六" };
private String[] stringMonth = new String[] { "Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
}
getContentPane().add(comboYear);
comboYear.addItemListener(this);
final JLabel labelYear = new JLabel();
labelYear.setForeground(Color.RED);
labelYear.setFont(new Font("新宋体", Font.PLAIN, 14));
/**
* 实现简单的日历功能
*
* @author Jadie version 1.02009/12/29
*
*/
private static final long serialVersionUID =1L;
public static void main(String args[]) {
try {
Calender2 frame = new Calender2();
for (int m = 1; m < 13; m++) {
comboMonth.addItem(" " + new Integer(m).toString());
}
getContentPane().add(comboMonth);
comboMonth.addItemListener(this);
getContentPane().add(labelMonth);
getContentPane().add(labelYear);
labelYear.setText(" 年");
comboMonth.setForeground(new Color(0, 0, 255));
comboMonth.setFont(new Font("", Font.PLAIN, 14));
labelMonth.setForeground(Color.BLUE);
labelMonth.setFont(new Font("新宋体", Font.PLAIN, 14));
labelMonth.setText(" 月");
getContentPane().add(buttonLastMonth);
date = gregorianCalendar.getTime();
strSysNowTime = (date + "").split(" ");
}
public void getSysTimeInfo() {
// 得到系统当前的时间信息并存储在字符串数组strSysTime中
date = gregorianCalendar.getTime();
super("万年历---揭德华制作2010-01-02");
getContentPane().setLayout(new GridLayout(8, 7, 3, 5));
setBounds(250, 200, 530, 360);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
二、
2.1
图2.1万年历框架图
2.2
图2.2日历设计框架图
三、
3.1
图3.1
图3.2
3.2
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

一、系统分析
1.1
本系统主要讲述如何利用JCreatorPro和SQL Server等工具完成万年历程序的开发,它主要为日期的查询,该系统除了可以实现现在的日期的查询之外,还可以实现对过去和未来年份日期的查询。!
1.2
操作系统:Windows XP/Server 2003
开发语言:JAVA
开发工具:JCreatorPro
getContentPane().add(buttonWeek[i]);
}
for (int i = 0; i < 42; i++) {
buttonDay[i] = new JButton();
buttonDay[i].setText("");
getContentPane().add(buttonDay[i]);
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.JButton;
month = i;
break;
}
}
return month;
}
public int weekStrat(String strWeek) {
// 返回字符串strWeek与星期中的第几天匹配,SUN为第一天
int strat = 0;
for (int i = 0; i < 7; i++) {
if (strWeek.equalsIgnoreCase(stringWeek[i])) {
buttonToday.addActionListener(this);
getContentPane().add(buttonNextMonth);
buttonNextMonth.setForeground(Color.BLUE);
buttonNextMonth.setFont(new Font("新宋体", Font.PLAIN, 14));
buttonWeek[i].setForeground(Color.RED);
} else {
buttonWeek[i].setForeground(Color.BLUE);
}
buttonWeek[i].setFont(new Font("新宋体", Font.PLAIN, 12));
buttonWeek[i].setText(stringWeekCn[i]);
setDate(-1);
} else {
setDate(1);
}
}
public void itemStateChanged(ItemEvent arg0) {
setDate(0);
}
public void getSysNowTimeInfo() {
// 得到程序运行时的时间信息并存储在字符串数组strSysNowTime中
buttonNextMonth.setText("下月");
buttonNextMonth.addActionListener(this);
for (int i = 0; i < 7; i++) {
buttonWeek[i] = new JButton();
if (i == 0 || i == 6) {
strSysTime = (date + "").split(" ");
}
public int getNowMonth() {
int month = 0;
for (int i = 0; i < 12; i++) {
if (strSysNowTime[1].equalsIgnoreCase(stringMonth[i])) {
private JButton[] buttonWeek = new JButton[7];
private JLabel labelMonth = new JLabel();
private JButton buttonToday = new JButton();
private JButton buttonLastMonth = new JButton();
private String[] stringWeek = new String[] { "SUN", "MON", "TUE", "WED",
"THU", "FRI", "SAT" };
private String[] stringWeekCn = new String[] { "星期天", "星期一", "星期二", "星期三",
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == buttonToday) {
setNowDate();
setNowDate();
} else if (ae.getSource() == buttonLastMonth) {
buttonLastMonth.setForeground(Color.BLUE);
buttonLastMonth.setFont(new Font("新宋体", Font.PLAIN, 14));
buttonLastMonth.setText("上月");
buttonLastMonth.addActionListener(this);
1.3
经过对万年历的程序编写和运行操作,最终我们确定该系统主要完成了以下这些功能:
1.日历、事件的分层次日程管理的方式便于用户更好的安排个人事务;
2.能够很方便的关注事情\任务录入,且可以通过快捷键直接调出;
3.可以很好的满足用户随时关注事件、任务的需求,同时在您关注其他工作的时候,它可以缩小到可忽略不计的程度;
相关文档
最新文档