您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > Java课程设计报告(广厦)
Java程序设计——课程设计报告班级:______10计软本____姓名:______曲冬雪_______学号:___1010711110___日期:2011-12-15广厦学院目录1.设计内容..........................................................................................................................................12.概要设计..........................................................................................................................................13.自定义类及接口说明.......................................................................................错误!未定义书签。4.程序源码..........................................................................................................................................15.程序运行与调试............................................................................................................................136.总结................................................................................................................................................147.参考文献........................................................................................................................................141标题:(样式选择标题1,段前端后10磅,三号字体,1.5倍行距)正文:(小四字体,1.5倍行距)参考文献(5号字体,1.5倍行距)1、设计内容通过编写一个基于JAVA的应用系统综合实例,自定义一个日历组件显示日期和时间并进行适当的功能扩充,实践Java语言编程技术。2、概要设计设计一个类用来构成日历系统的主窗口,然后编写一个框架类显示时间和提示信息。在设计中应用了多种容器和控件。3、自定义类及接口说明(1)publicvoidupdateView()改变日期后完成更新界面;(2)抽象类java.util.Calendar获取系统日期并传递日期数据而且在人工改变日期后得出当天是周几;(3)publicstaticvoidmain(String[]args)主函数完成系统各算法的调用并对主窗口的一些属性进行设置;4、程序源码/***@(#)MyCalendar.java*@authorfancy*///日历使用的类importjava.awt.BorderLayout;importjava.awt.Color;2importjava.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;3publicstaticfinalStringWEEK_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(单击此处查看时间);4button1.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,daymaxDay?maxDay:day);updateView();5}});JPanelyearMonthPanel=newJPanel();cPane.add(yearMonthPanel,BorderLayout.NORTH);yearMonthPanel.setLayout(newBorderLayout());yearMonthPanel.add(newJPanel(),BorderLayout.CENTER);JPanelyearPanel=newJPanel();yearMonthPanel.add(yearPanel,BorderLayout.WEST);yearPanel.setLayout(newBorderLayout());yearPanel.add(yearsLabel,BorderLayout.WEST);yearPanel.add(yearsSpinner,BorderLayout.CENTER);monthsLabel=newJLabel(Month:);monthsComboBox=newJComboBox();for(inti=1;i=12;i++){monthsComboBox.addItem(newInteger(i));}monthsComboBox.setSelectedIndex(calendar.get(Calendar.MONTH));monthsComboBox.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventactionEvent){intday=calendar.get(Calendar.DAY_OF_MONTH);calendar.set(Calendar.DAY_OF_MONTH,1);calendar.set(Calendar.MONTH,monthsComboBox.getSelectedIndex());intmaxDay=calendar.g
本文标题:Java课程设计报告(广厦)
链接地址:https://www.777doc.com/doc-3804138 .html