谁能用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();
}
}
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)
-
佚名2024-12-23 14:26:11
问j**a编写一个多功能万年历程序
答import j**a.io.*;class putout{public void putout(int f,int x,int y){int i;int a[...
-
佚名2024-12-23 20:43:18
问用j**a编写万年历需要建几个类
答3个差不多了,最好分开,看得清楚些
-
佚名2024-12-23 10:22:23
问谁能用c++编写计算万年历程序啊?
答说实话,编写这样一个东东有点麻烦,况且lz只用零分~参考http://我去年编写的,里面没有“显示某一年某一个月的日历”的功能,但是你参考其他功能自己写一下吧。...
-
佚名2024-12-23 17:07:31
问急!~~~~ 用c或者c++编写 打印万年历 的程序 要求如下
答基本功能已经实现:/***************************************************************** *aut...
-
佚名2024-12-23 03:11:37
问谁能告诉我一个笑话,越搞笑越好!
答你好,我来为你解答:先来两个笑话吧,啊?哈更多在空间奥,哈哈。1、有次等公共汽车时,开过去一辆宝马,旁边一位高人对他身边的人说:“看,刚过去那辆就是ibm。”2...
-
佚名2024-12-23 08:00:00
问谁能帮我做一个关于家庭塑料袋的使用情况的研究报告,越快越好,1500字以上
答参**: 要乐观,要积极,多笑,多照镜子。
-
佚名2024-12-23 08:00:00
问用c#编写一个万年历程序
答借贵宝地拿点经验,不谢
-
佚名2024-12-23 08:00:00
问球大神帮帮,设计一个万年历 功能如下
答依你以上描述 你可以去央视的我爱发明
-
佚名2024-12-23 08:00:00
问用c++编写的万年历代码
答#include <iostream> #include <iomanip.h> using namespace std;class data //...
-
佚名2024-12-23 08:00:00
问这是别人写的代码。谁能给我解释一下是什么意思啊。 越清楚越好,越详细越好。
答这个是html5-canvas的一个具体使用实例。意思是已定义的gradient对象(画布上的一个位置),添加一个逐步变白,并渐变为透明色的特效。其中addco...
风水
起名
网名
- 1 好黄好暴力的网名
- 2 王者荣耀形容躺赢的网名
- 3 衬托海鸥的网名
- 4 ssh 主机昵称是什么
- 5 大唐麻将怎样改昵称
- 6 形容未来会更好的昵称
- 7 木蚂蚁乐园修改昵称
- 8 百度贴吧改昵称活动太火了
- 9 联盟5字昵称
- 10 丸子同学昵称
说说
- 1 有关情人节的个性签名
- 2 深奥的爱情个性签名
- 3 经商者个性签名
- 4 男人突然换个性签名
- 5 qq飞车个人签名咋变色
- 6 说说广告的日记
- 7 赞美熊猫说说
- 8 关于晴空万里的说说
- 9 天气一下子变冷的说说
- 10 心太累的简短说说