java布局和日历案例实现效果如图:
三个类实现
CalendarMainClass.java
public class CalendarMainClass {
public static void main(String args[]) {
CalendarFrame frame=new CalendarFrame();
frame.setBounds(100,100,360,300);
frame.setVisible(true);
frame.setYearAndMonth(2015,5);
}
}
CalendarBean.java
import java.util.Calendar;
public class CalendarBean {
String day[];
int year=2005,month=0;
public void setYear(int year) {
this.year=year;
}
public int getYear() {
return year;
}
public void setMonth(int month) {
this.month=month;
}
public int getMonth() {
return month;
}
public String[] getCalendar() {
String a[]=new String[42];
Calendar 日历=Calendar.getInstance();
日历.set(year,month-1,1);
int 星期几=日历.get(Calendar.DAY_OF_WEEK)-1;
int day=0;
if(month==1||month==3||month==