日历;单击previousMonth按钮,可以显示当前月的上一月的日历。窗口的南面添加一 个Panel容器pSouth,其布局是FlowLayout布局,pSouth中放置一个标签用来显示一些信息。
package gaoshuang;
import java.util.Calendar;
publicclass CalendarBean {
String day[];
intyear=2005,month=0;
publicvoid setYear(intyear)
{
this.year=year;
}
publicint getYear()
{
returnyear;
}
publicvoid setMonth(intmonth)
{
this.month=month;
}
publicint getMonth()
{
returnmonth;
}
public String[] getCalendar()
{
String a[]=new String[42];
Calendar 日历=Calendar.getInstance();
日历.set(year,month-1,1);
int星期几=日历.get(Calendar.DAY_OF_WEEK)-1;
intday=0;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
{
day=31;
}
if(month==4||month==6||month==9||month==11)
{
day=30;
}
if(month==2)
{
if(((year%4==0)&&(year%100!=0))||(year%400==0))
{
day=29;
}
else{
day=28;
}
}
for(inti=星期几,n=1;i<星期几+day;i++)
{
a[i]=String.valueOf(n) ; n++;
}
returna;
}
}
package gaoshuang;
importjava.util.*;
import java.awt.*;
import java.awt.event.*;
importjava.applet.*;
publicclassCalendarFrameextends Frame implements ActionListener
{
Label labelDay[]=new Label[42];
Button titleName[]=new Button[7];
JTextField m_monster = new JTextField("输入年份:",12);
String name[]={
"日",