java课程设计简单日历word文档良心出品.docx

上传人:b****4 文档编号:851846 上传时间:2022-10-13 格式:DOCX 页数:15 大小:55.07KB
下载 相关 举报
java课程设计简单日历word文档良心出品.docx_第1页
第1页 / 共15页
java课程设计简单日历word文档良心出品.docx_第2页
第2页 / 共15页
java课程设计简单日历word文档良心出品.docx_第3页
第3页 / 共15页
java课程设计简单日历word文档良心出品.docx_第4页
第4页 / 共15页
java课程设计简单日历word文档良心出品.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

java课程设计简单日历word文档良心出品.docx

《java课程设计简单日历word文档良心出品.docx》由会员分享,可在线阅读,更多相关《java课程设计简单日历word文档良心出品.docx(15页珍藏版)》请在冰豆网上搜索。

java课程设计简单日历word文档良心出品.docx

java课程设计简单日历word文档良心出品

java课程设计报告

 

题目:

JAVA简易时间日历程序

*************

学号:

**********

专业班级:

信101

********

 

课程设计题目

题目说明

通过编写一个基于JAVA的应用系统综合实例,自定义一个日历组件显示日期和时间并进行适当的功能扩充,实践Java语言编程技术。

系统设计

1设计目标

一个完整的程序应具有以下功能:

1)显示当月日历、当前日期、当前时间;

2)可查寻任意月以及任意年的日历;

3)使用图形化界面能够弹出对话框;

5)正常退出程序。

2设计思想

设计一个类用来构成日历系统的主窗口,然后编写一个框架类显示时间和提示信息。

在设计中应用了多种容器和控件。

系统模块划分

publicstaticclassCalendarTable(日历类)

publicstaticvoidmain(String[]args)

publicstaticclassRollbyJFrame

(滚动时间类)

publicclassMyCalendarextendsJApplet

(主日历框架类)

图1:

简易日历的程序结构图

初始化:

publicvoidinit()完成界面初始化,形成一个以挂历形式显示当前日期的窗口。

日历描述:

  

(1)publicvoidupdateView()改变日期后完成更新界面;

 

(2)抽象类java.util.Calendar获取系统日期并传递日期数据而且在人工改变日期后得出当天是周几;

 (3)publicstaticvoidmain(String[]args)

主函数完成系统各算法的调用并对主窗口的一些属性进行设置;

滚动时间:

  将时间以文本的形式在文本框中滚动播出,并能改变滚动的速度。

4.使用类及接口

仅仅简单说明类的功能,详细资料请参看《JavaTM 2 PlatformStandard Ed.6》的电子文档,常规的接口与包则省略不屑。

//以下是日历程序块中使用的类

packagefancy;

importjava.awt.*;

importjava.awt.event.*;

importjava.util.*;//主要用此包中的日期和时间类

importjavax.swing.*;

importjavax.swing.event.*;

importjavax.swing.table.*;

//以下是对滚动时间程序块所使用的类和接口,

用到定时器类Timer

importjava.awt.Color;

importjava.awt.FlowLayout;

importjava.awt.event.ActionListener;

importjava.awt.event.ActionEvent;

importjava.awt.event.FocusListener;、

//用于监听鼠标单击(焦点改变)事件

importjava.awt.event.FocusEvent;

//用于响应鼠标单击(焦点改变)事件、

importjavax.swing.JFrame;

importjavax.swing.JTextField;

importjavax.swing.JSpinner;

//让用户从一个有序序列中选择一个数字或者一个对象值的单行输入字段。

importjavax.swing.JPanel;

importjavax.swing.Timer;

//在指定时间间隔触发一个或多个ActionEvent,创建一个Timer对象,在该对象上注册一个或多个动作侦听器,以及使用start方法启动该计时器。

并配合事件监听器支持时间的滚动播放。

importjavax.swing.event.ChangeListener;

importjavax.swing.event.ChangeEvent;

5.运行结果与分析

图2:

初始界面显示日历。

图3:

点击查看时间按钮,

弹出时间消息对话框。

图4:

滚动显示当前时间。

 

程序源代码

MyCalendar.java

importjava.awt.BorderLayout;

importjava.awt.Color;

importjava.awt.Component;

importjava.awt.Container;

importjava.awt.FlowLayout;

importjava.awt.event.ActionEvent;

importjava.awt.event.ActionListener;

importjava.awt.event.FocusEvent;

importjava.awt.event.FocusListener;

importjava.util.Calendar;

importjavax.swing.JApplet;

importjavax.swing.JButton;

importjavax.swing.JComboBox;

importjavax.swing.JFrame;

importjavax.swing.JLabel;

importjavax.swing.JOptionPane;

importjavax.swing.JPanel;

importjavax.swing.JSpinner;

importjavax.swing.JTable;

importjavax.swing.JTextField;

importjavax.swing.ListSelectionModel;

importjavax.swing.Timer;

importjavax.swing.event.ChangeEvent;

importjavax.swing.event.ChangeListener;

importjavax.swing.table.AbstractTableModel;

importjavax.swing.table.TableCellRenderer;

importjavax.swing.table.TableModel;

//日历

publicclassMyCalendarextendsJApplet

{

publicstaticfinalStringWEEK_SUN="SUN";

publicstaticfinalStringWEEK_MON="MON";

publicstaticfinalStringWEEK_TUE="TUE";

publicstaticfinalStringWEEK_WED="WED";

publicstaticfinalStringWEEK_THU="THU";

publicstaticfinalStringWEEK_FRI="FRI";

publicstaticfinalStringWEEK_SAT="SAT";

publicstaticfinalColorbackground=Color.yellow;

publicstaticfinalColorforeground=Color.black;

publicstaticfinalColorheaderBackground=Color.blue;

publicstaticfinalColorheaderForeground=Color.white;

publicstaticfinalColorselectedBackground=Color.blue;

publicstaticfinalColorselectedForeground=Color.white;

privateJPanelcPane;

privateJLabelyearsLabel;

privateJSpinneryearsSpinner;

privateJLabelmonthsLabel;

privateJComboBoxmonthsComboBox;

privateJTabledaysTable;

privateAbstractTableModeldaysModel;

privateCalendarcalendar;

privateJButtonbutton1;

publicMyCalendar(){

cPane=(JPanel)getContentPane();

}

publicvoidinit(){

cPane.setLayout(newBorderLayout());

calendar=Calendar.getInstance();

calendar=Calendar.getInstance();

JButtonbutton1=newJButton("单击此处查看时间");

button1.setBounds(10,10,10,10);

cPane.add(button1,BorderLayout.SOUTH);

button1.addActionListener(

newjava.awt.event.ActionListener()

{publicvoidactionPerformed(ActionEvente){

RollbyJFramemyrili=newRollbyJFrame();

JOptionPane.showMessageDialog(null,"您点击了"+e.getActionCommand().toString()+"按钮");

}

}

);

yearsLabel=newJLabel("Year:

");

yearsSpinner=newJSpinner();

yearsSpinner.setEditor(newJSpinner.NumberEditor(yearsSpinner,"0000"));

yearsSpinner.setValue(newInteger(calendar.get(Calendar.YEAR)));

yearsSpinner.addChangeListener(newChangeListener(){

publicvoidstateChanged(ChangeEventchangeEvent){

intday=calendar.get(Calendar.DAY_OF_MONTH);

calendar.set(Calendar.DAY_OF_MONTH,1);

calendar.set(Calendar.YEAR,((Integer)yearsSpinner.getValue()).intValue());

intmaxDay=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

calendar.set(Calendar.DAY_OF_MONTH

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1