使用JavaJTable实现日历功能-创新互联

这期内容当中小编将会给大家带来有关使用Java JTable 实现日历功能,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

创新互联主营兰溪网站建设的网络公司,主营网站建设方案,成都app软件开发公司,兰溪h5小程序开发搭建,兰溪网站营销推广欢迎兰溪等地区企业咨询

MyCalendar类:

得到用于显示日期数组a[ ]

import java.util.Calendar;

public class MyCalendar {
String day[];
int year = 2020,month=0;

public String[] getDay() {
return day;
}
public void setDay(String[] day) {
this.day = day;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
private boolean isLeapYear() {
if(this.year%4==0 && this.year%100!=0){
return true;
}else 
if(this.year%400==0){
return true;
}else

return false;
}


//获得显示数组
public String[] getCalendar(){
Calendar calendar=Calendar.getInstance();
String a[]=new String[42];
calendar.set(year,month-1,1);
int weekday=calendar.get(Calendar.DAY_OF_WEEK)-1;
int day=0;
int days = 31;
if (this.month == 4 || this.month == 6 || this.month == 9 || this.month == 11)
days = 30;
if (this.month == 2 && isLeapYear())
days = 29;
if (this.month == 2 && !isLeapYear())
days = 28;

for(int i = weekday,n=1;i< weekday +days;i++){
a[i]=String.valueOf(n);
n++;
}
return a;
}

}

网页标题:使用JavaJTable实现日历功能-创新互联
网页URL:http://scyanting.com/article/cdodej.html