|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
认真的记,感觉很紧张根本就没有时间和能力,来对技术知识点进行思考。这样课下就只能对知识进行简单的理解,其实简单的理解就是记忆课堂上讲的知识点,
packagecalendar;
importjava.awt.*;
importjava.awt.event.*;
importjava.applet.*;
importjavax.swing.*;
publicclassCalendarV2extendsApplet{
privatebooleanisStandalone=false;
//Getaparametervalue
publicStringgetParameter(Stringkey,Stringdef){
returnisStandalone?System.getProperty(key,def):
(getParameter(key)!=null?getParameter(key):def);
}
//Constructtheapplet
publicCalendarV2(){
}
//Initializetheapplet
publicvoidinit(){
try{
jbInit();
}
catch(Exceptione){
e.printStackTrace();
}
}
//Componentinitialization
privatevoidjbInit()throwsException{
jLabel1.setText("PleaseEnterYear");
jLabel1.setBounds(newRectangle(8,30,114,26));
this.setLayout(null);
jTextField1.setText("");
jTextField1.setBounds(newRectangle(129,30,136,27));
jLabel2.setText("PleaseEnteMonth");
jLabel2.setBounds(newRectangle(4,70,104,26));
jTextField2.setText("");
jTextField2.setBounds(newRectangle(130,69,136,26));
jButton1.setBounds(newRectangle(16,122,233,21));
jButton1.setText("CheckCalendarV2");
jButton1.addActionListener(newCalendarV2_jButton1_actionAdapter(this));
jButton2.setBounds(newRectangle(16,156,232,20));
jButton2.setText("Exit");
jButton2.addActionListener(newCalendarV2_jButton2_actionAdapter(this));
this.add(jButton1,null);
this.add(jTextField1,null);
this.add(jTextField2,null);
this.add(jLabel2,null);
this.add(jLabel1,null);
this.add(jButton2,null);
}
JLabeljLabel1=newJLabel();
JTextFieldjTextField1=newJTextField();
JLabeljLabel2=newJLabel();
JTextFieldjTextField2=newJTextField();
JButtonjButton1=newJButton();
//GetAppletinformation
publicStringgetAppletInfo(){
return"AppletInformation";
}
//Getparameterinfo
publicString[][]getParameterInfo(){
returnnull;
}
//Mainmethod
publicstaticvoidmain(String[]args){
CalendarV2applet=newCalendarV2();
applet.isStandalone=true;
Frameframe;
frame=newFrame();
frame.setTitle("AppletFrame");
frame.add(applet,BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimensiond=Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width-frame.getSize().width)/2,(d.height-frame.getSize().height)/2);
frame.setVisible(true);
}
//DeclaredataMember
//********************
booleanisLeapYear,isEverPressBtn=false;
intthisYear,EnterYear,EnterMonth;
//***********************************************************************************
//Methods
//***********************************************************************************
//-----盘算该年天数---------------
publicintcheckYear(intYear){
if(Year%4==0&&Year%100!=0){
thisYear=366;
}
if(Year%100==0&&Year%400==0){
thisYear=366;
}
elseif(Year%4!=0){
thisYear=365;
}
returnthisYear;
}
//--------------------------------
//------检察是不是闰年----------------
publicbooleancheckLeapYear(intYear){
if(Year%4==0&&Year%100!=0){
isLeapYear=true;
}
if(Year%400==0)
isLeapYear=true;
elseif(Year%4!=0){
isLeapYear=false;
}
returnisLeapYear;
}
//---------------------------------
//--------盘算当月天数---------------
//要输出年份的缘故原由是要判别仲春29天仍是28天
publicintcheckMonth(intMonth,intYear){
intDates=0;
if(Month<0||Month>12){
System.out.println("MonthError");
}
if(Month==1||Month==3||Month==5||
Month==7||Month==8||Month==10||
Month==12){
Dates=31;
}
if(Month==2&&this.checkLeapYear(Year)){
Dates=29;
}
if(Month==2&&!this.checkLeapYear(Year)){
Dates=28;
}
if(Month==4||Month==6||Month==9||Month==11){
Dates=30;
}
returnDates;
}
//------------------------------------
//-----用递回法盘算方针年到已知年的总天数---
publicintcounterYearDates(intEnterYear){
intsum1=0;
if(EnterYear==2001){//2001年为已知年
sum1=0;//递回今后跳出
}
if(EnterYear>2001){
sum1+=this.checkYear(EnterYear-1)
+this.counterYearDates(EnterYear-1);
}
//当方针年年夜于2001年,则从方针年-1往前累加
//到2001年为止
if(EnterYear<2001){
sum1+=this.checkYear(EnterYear)
+this.counterYearDates(EnterYear+1);
}
//当方针年小于2001年,则从方针年今后累加
//到2001年为止
returnsum1;
}
//-----盘算方针年从一月到方针月的总天数------------------------
//要输出年份的缘故原由是要判别仲春29天仍是28天
publicintcounterMonthDates(intEnterMonth,intEnterYear){
intsum2=0;
if(EnterMonth==1){
sum2=0;
}
if(EnterMonth>1&&EnterMonth<=12){
sum2+=this.checkMonth(EnterMonth-1,EnterYear)
+this.counterMonthDates(EnterMonth-1,EnterYear);
}
elseif(EnterMonth<0){
System.out.print("MonthError");
}
returnsum2;
}
//------------------------------------------------
//-------------用数组存方针月日期-----------------------------
publicint[]Array(intAllDates,intEnterMonth){
intn=AllDates%7;
inta=1;
int[]DayInTable=newint[38];
if(n<0)//Keepthenbiggerthan0
n=7+n+1;//Line207haven |
|