您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > java程序设计报告2万年历
程序设计报告JAVA设计报告2:万年历姓名:王颖学号:61541220314001学习中心:延安富县学习中心专业:计算机科学与技术层次:专升本身份证号:610628198607190023联系电话:18509112033万年历程序设计一、设计分析万年历有很多作用,顾名思义它是一种很方便得计时计年工具,随着科技得发展,我们已经可以通过计算机制作出精美的万年历,通过计算机制作得万年历不但外观美观,而且功能强大。通过万年历,我们可以实现很多功能,随意看某年得年份,某年得月份,随意调整某年得某天,并将其显示出来,而且有判断闰年闰月得功能,十分方便。二、程序流程框图主程序流程图开始初始化读、写日期、时间分离日期\时间\显示子程序农历自动更新子程序日期、时间修改子程序闰月子程返回定时子程序三、具体设计1、变量设计表2变量表成员变量描述变量类型名称年、月、日intYear、month、day下一年,下一月IntYearafterquery,monthafterquey开始的时间Intstartday选择月,天StringSwitchMonth,key,day改变年改变月前一月,前一年判断是否改变左、又面板年、月左上角信息标签显示月、年标签空格标签右上部时间标IntIntIntbooleanJPanelJLabelJLabelJLabelJLabelJLabelJLabel[]JComboBoxJButtonChangeyearmessagechangemonthmessagepriormonth,prioryearischange,ischange_priornextLeftPane,RightPaneYearLabel,MonthLabelAskShowDateBlankNorthMonthDayYearTopBarTitle[]MonthComboboxQuery签星期标签数组月份下拉列表时间确定按钮保存、删除按钮前、下一月按钮文本区星期字符串数组显示天的文本区输入年的文本区JButtonJButtonJTextAreaStringJTextFieldJTextFieldSouthSave,SouthDeletePriorMonth,NextMonthCenterTextweek[]ShowDays[]YearText2、程序源代码importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjavax.swing.event.*;importjavax.swing.border.*;importjava.util.Calendar;importjava.util.*;importjava.io.*;importjava.io.IOException;publicclasscalendarextendsJFrameimplementsActionListener,MouseListener{intyear,month,day;intyearafterquery,monthafterquery;intstartday;StringSwitchMonth;Stringkey;intchangeyearmessage;intchangemonthmessage;intpriormonth;intprioryear;booleanischange=false;booleanischange_priornext=false;privateJPanelLeftPane,RightPane;//LeftsubprivateJLabelYearLabel;privateJLabelMonthLabel;privateJComboBoxMonthCombobox;privateJTextFieldShowDays[]=newJTextField[42];privateJTextFieldYearText;privateJLabelAsk;privateJLabelShowDate;privateJLabelBlank;privateJLabelTopBarTitle[]=newJLabel[7];privateJButtonToToday;privateJButtonQuery;privateStringweek[]={SUN,MON,TUE,WED,THU,FRI,SAT};//rightsubprivateJLabelNorthMonthDayYear;privateJTextAreaCenterText;privateJButtonSouthSave,SouthDelete;privateJButtonPriorMonth;privateJButtonNextMonth;publiccalendar(intyear,intmonth,intday){setTitle(MyCalendar&Textbook);//thelayoutaboutleftofjpaneLeftPane=newJPanel();JPanelLeftCenter=newJPanel();JPanelLeftNorth=newJPanel();//JPanelLeftSouth=newJPanel();LeftPane.setLayout(newBorderLayout());LeftPane.add(LeftNorth,BorderLayout.NORTH);LeftPane.add(LeftCenter,BorderLayout.CENTER);LeftPane.add(ToToday=newJButton(Gototoday,newImageIcon(../images/Handle.gif)),BorderLayout.SOUTH);ToToday.setBackground(Color.cyan);ToToday.addActionListener(this);LeftPane.validate();//thelayoutofLeftPane//LeftPane_NorthLeftNorth.setLayout(newGridLayout(3,1,0,-2));LeftNorth.add(Ask=newJLabel(Pleseinputtheinformationswhichyouwantquery:));JPanelNorth=newJPanel(newFlowLayout(0,8,0));LeftNorth.add(North);North.add(YearLabel=newJLabel(Year:));North.add(YearText=newJTextField(4));YearText.setBackground(Color.getHSBColor(30,20,50));YearText.setForeground(Color.blue);YearText.setFont(newFont(TimesRoman,Font.BOLD,17));YearText.addActionListener(this);YearText.setFocusable(true);North.add(Blank=newJLabel());North.add(MonthLabel=newJLabel(Month:));North.add(MonthCombobox=newJComboBox());//addmonthtomonthcomboboxfor(inti=1;i=12;i++){MonthCombobox.addItem(newInteger(i));}//SwitchthemonthMonthCombobox.setForeground(Color.blue);MonthCombobox.setFont(newFont(TimesRoman,Font.BOLD,12));North.add(Blank=newJLabel());North.add(Query=newJButton(Query));Query.setForeground(Color.blue);Query.addActionListener(this);JPanelNorth2=newJPanel(newFlowLayout());LeftNorth.add(North2);North2.add(PriorMonth=newJButton(newImageIcon(../images/prior.gif)));PriorMonth.addActionListener(this);PriorMonth.setActionCommand(prior);priormonth=month;prioryear=year;SwitchMonth(month);North2.add(ShowDate=newJLabel(SwitchMonth++,++String.valueOf(year),SwingConstants.CENTER));ShowDate.setForeground(Color.blue);ShowDate.setFont(newFont(TimesRoman,Font.BOLD,14));North2.add(NextMonth=newJButton(newImageIcon(../images/next.gif)));NextMonth.addActionListener(this);NextMonth.setActionCommand(next);//LeftPane_CenterLeftCenter.setLayout(newGridLayout(7,7));//printtitlefor(inti=0;i7;i++){TopBarTitle[i]=newJLabel();TopBarTitle[i].setText(week[i]);TopBarTitle[i].setForeground(Color.darkGray);TopBarTitle[i].setHorizontalAlignment(0);TopBarTitle[i].setBackground(Color.MAGENTA);TopBarTitle[i].setBorder(BorderFactory.createRaisedBevelBorder());LeftCenter.add(TopBarTitle[i]);}//printscreenandaddlistenerfor(inti=0;i42;i++){ShowDays[i]=newJTextField();ShowDays[i].addMouseListener(this);ShowDays[i].setEditable(false);LeftCenter.add(ShowDays[i]);}//printthebodyofmonthPrintMonth(year,month,day);//thelayoutaboutrightofjpaneRightPane=newJPanel(newBorderLayout());JPanelRightCenter=newJPanel();JPanelRightNorth=newJPanel();JPanelRightSouth=newJPanel(newFlowLayout());RightPane.add(RightNorth,BorderLayout.NORTH);RightPane.add(RightCenter,BorderLayout.CENTER);RightPane.add(RightSouth,BorderLayout.SOUTH);RightNorth.add(NorthMonthDayYear=newJLabel(+year+,+SwitchMonth+,+day+));key=year+_+SwitchMon
本文标题:java程序设计报告2万年历
链接地址:https://www.777doc.com/doc-2878856 .html