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

上传人:人*** 文档编号:544851313 上传时间:2023-06-23 格式:DOC 页数:15 大小:114.04KB
返回 下载 相关 举报
java课程设计简单日历(word文档良心出品).doc_第1页
第1页 / 共15页
java课程设计简单日历(word文档良心出品).doc_第2页
第2页 / 共15页
java课程设计简单日历(word文档良心出品).doc_第3页
第3页 / 共15页
java课程设计简单日历(word文档良心出品).doc_第4页
第4页 / 共15页
java课程设计简单日历(word文档良心出品).doc_第5页
第5页 / 共15页
点击查看更多>>
资源描述

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

1、Java 课程设计报告 信101 董兆军 2010314120java课程设计报告题 目 : JAVA简易时间日历程序学生姓名 : 董兆军 学 号 :2010314120 专业班级 : 信101 指导教师 : 李红强 课程设计题目 题目说明通过编写一个基于JAVA的应用系统综合实例,自定义一个日历组件显示日期和时间并进行适当的功能扩充,实践Java语言编程技术。系统设计1 设计目标一个完整的程序应具有以下功能:1)显示当月日历、当前日期、当前时间;2)可查寻任意月以及任意年的日历;3)使用图形化界面能够弹出对话框;5)正常退出程序。 2 设计思想设计一个类用来构成日历系统的主窗口,然后编写一个

2、框架类显示时间和提示信息。在设计中应用了多种容器和控件。系统模块划分public static class CalendarTable(日历类)public static void main(String args)public static class RollbyJFrame(滚动时间类)public class MyCalendar extends JApplet(主日历框架类)图1:简易日历的程序结构图初始化: public void init()完成界面初始化,形成一个以挂历形式显示当前日期的窗口。 日历描述: (1)public void updateView()改变日期后完成更新

3、界面; (2)抽象类java.util.Calendar获取系统日期并传递日期数据而且在人工改变日期后得出当天是周几; (3)public static void main(String args)主函数完成系统各算法的调用并对主窗口的一些属性进行设置; 滚动时间: 将时间以文本的形式在文本框中滚动播出,并能改变滚动的速度。4. 使用类及接口仅仅简单说明类的功能,详细资料请参看 JavaTM2Platform StandardEd. 6的电子文档,常规的接口与包则省略不屑。/以下是日历程序块中使用的类package fancy; import java.awt.*; import java.a

4、wt.event.*; import java.util.*; /主要用此包中的日期和时间类import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*;/以下是对滚动时间程序块所使用的类和接口,用到定时器类Timerimport java.awt.Color;import java.awt.FlowLayout;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.awt.event.Foc

5、usListener;、/用于监听鼠标单击(焦点改变)事件import java.awt.event.FocusEvent;/用于响应鼠标单击(焦点改变)事件、import javax.swing.JFrame;import javax.swing.JTextField;import javax.swing.JSpinner;/让用户从一个有序序列中选择一个数字或者一个对象值的单行输入字段。import javax.swing.JPanel;import javax.swing.Timer;/在指定时间间隔触发一个或多个 ActionEvent, 创建一个 Timer 对象,在该对象上注册一个

6、或多个动作侦听器,以及使用 start 方法启动该计时器。并配合事件监听器支持时间的滚动播放。import javax.swing.event.ChangeListener;import javax.swing.event.ChangeEvent;5. 运行结果与分析图2:初始界面显示日历。图3:点击查看时间按钮, 弹出时间消息对话框。图4:滚动显示当前时间。程序源代码MyCalendar.java import java.awt.BorderLayout;import java.awt.Color;import java.awt.Component;import java.awt.Conta

7、iner;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.FocusEvent;import java.awt.event.FocusListener;import java.util.Calendar;import javax.swing.JApplet;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.

8、JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JSpinner;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.ListSelectionModel;import javax.swing.Timer;import javax.swing.event.ChangeEvent;import javax.swing.event.C

9、hangeListener;import javax.swing.table.AbstractTableModel;import javax.swing.table.TableCellRenderer;import javax.swing.table.TableModel;/日历 public class MyCalendar extends JApplet public static final String WEEK_SUN = SUN; public static final String WEEK_MON = MON; public static final String WEEK_T

10、UE = TUE; public static final String WEEK_WED = WED; public static final String WEEK_THU = THU; public static final String WEEK_FRI = FRI; public static final String WEEK_SAT = SAT; public static final Color background = Color.yellow; public static final Color foreground = Color.black; public static

11、 final Color headerBackground = Color.blue; public static final Color headerForeground = Color.white; public static final Color selectedBackground = Color.blue; public static final Color selectedForeground = Color.white; private JPanel cPane; private JLabel yearsLabel; private JSpinner yearsSpinner;

12、 private JLabel monthsLabel; private JComboBox monthsComboBox; private JTable daysTable; private AbstractTableModel daysModel; private Calendar calendar; private JButton button1; public MyCalendar() cPane = (JPanel) getContentPane(); public void init() cPane.setLayout(new BorderLayout(); calendar =

13、Calendar.getInstance(); calendar = Calendar.getInstance(); JButton button1=new JButton( 单击此处 查看时间 ); button1.setBounds(10,10,10,10); cPane.add(button1,BorderLayout.SOUTH); button1.addActionListener( new java.awt.event.ActionListener() public void actionPerformed(ActionEvent e) RollbyJFrame myrili=ne

14、w RollbyJFrame(); JOptionPane.showMessageDialog(null, 您点击了+e.getActionCommand().toString()+按钮); ); yearsLabel = new JLabel(Year: ); yearsSpinner = new JSpinner(); yearsSpinner.setEditor(new JSpinner.NumberEditor(yearsSpinner, 0000); yearsSpinner.setValue(new Integer(calendar.get(Calendar.YEAR); yearsSpinner.addChangeListener(new ChangeListener()

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号