QQ网名大全

谁能用j**a或vb帮我编写一个好使的万年历。功能越强大越好。跪求。

表格显示的日历

import j**a.awt.*;
import j**a.awt.event.*;
import j**ax.swing.*;
import j**ax.swing.table.*;
import j**ax.swing.event.*;
import j**a.util.*;

class calendardemo extends jframe{
jtable table;
string title[]={"日","一","二","三","四","五","六"};
string value[][]=new string[6][7];
string a[];
calendar cal=calendar.getinstance();
gregoriancalendar gcal=new gregoriancalendar();
int year,month,day;
int mon[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
jcombobox combyear,combmonth;
borderlayout layout=new borderlayout();
container c;
jpanel p1=new jpanel(new borderlayout());
public calendardemo() {
super("calendar");
c=th**.getcontentpane();
jpanel p=new jpanel(new flowlayout(flowlayout.center,20,0));
string y[]= {"2000","2001","2002","2003","2004","2005","2006",
"2007","2008","2009","2010"};
combyear=new jcombobox(y);
string []m={"1","2","3","4","5","6","7","8","9","10","11","12"};
combmonth=new jcombobox(m);
p.add(combyear);
p.add(combmonth);

year=cal.get(calendar.year);
month=cal.get(calendar.month);
combyear.setselectedindex(year-2000);
combmonth.setselectedindex(month);
c.add(p,borderlayout.north);
gettable(year,month);
combyear.additeml**tener(new iteml**tener(){
public void itemstatechanged(itemevent e) {
string y=(string)combyear.getselecteditem();
year=integer.parseint(y);

gettable(year,month);
// layout.layoutcontainer(c);
}
});
combmonth.additeml**tener(new iteml**tener(){
public void itemstatechanged(itemevent e) {
string m=(string)combmonth.getselecteditem();
month=integer.parseint(m)-1;

gettable(year,month);
// layout.layoutcontainer(c);
}
});

th**.setsize(300,200);
show();
}
void gettable(int year,int month)
{

if(gcal.**leapyear(year))
mon[2]=29;
cal.set(year,month,1);
int week=cal.get(calendar.day_of_week)-1;
string a[]=new string[37];

for(int i=0;i<a.length;i++)
a[i]=" ";
for(int i=week,n=1;i<week+mon[month+1];i++)
{
if(n<=9)
a[i]=" "+ n;
else
a[i]=string.valueof(n);
n++;
}
for(int i=0,j=0,k=0;i<a.length;i++ )
{
value[j][k]=a[i];
k++;
if(k%7==0)
{
j=j+1;
k=k%7;
}
}
table=new jtable(value,title);
jtableheader head=table.gettableheader();
p1.add(head,borderlayout.north);
p1.add(table,borderlayout.center);
c.add(p1);
validate();

}
public static void main(string[] args) {
calendardemo calendardemo = new calendardemo();
}

}
佚名
2024-12-23 14:15:43
最佳回答
类似问题(10)