import java.awt.*;
import java.awt.event.*;
import java.java.util.*;
public class MyCalender000 extends Frame implements ItemListener{
Choice good1=new Choice();
Choice good2=new Choice();
Panel p1=new Panel();
Panel p2=new Panel();
public MyCalender000(String title){
super(title);
int[] arr1=new int[200];
for(int i=0;i<arr1.length;i++)
arr1[i]=i+1900;
for(int i=0;i<200;i++)
good1.add(String.valueOf(arr1[i]));
int[] arr2=new int[12];
for(int i=0;i<arr2.length;i++)
arr2[i]=i+1;
for(int i=0;i<12;i++)
good2.add(String.valueOf(arr2[i]));
p1.setLayout(2,2);
p1.add(good1);
p1.add(good2);
add(p1,"NORTH");
good1.addItemListener(this);
good2.addItemListener(this);
}
public void itemStateChanged(ItemEvent e){
if(e.getSource()==good1||e.getSource()==good2)
paintoutcalender(good1.getSelectedItem(),good2.getSelectedItem());
}
public void paintoutcalender(string str1,string str2){
int Year=Integer.parseInt(str1);
int Mouth=Integer.parseInt(str2);
int a;
if(Year % 4 == 0 && Year % 100 != 0 || Year % 400 == 0)
a=28;
else a=29;
switch(Mouth){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:printsout(31);
case 4:
case 6:
case 9:
case 11:printsout(30);
case 2: printsout(a);
default :break;
}
public void printsout(int t){
string[] str=new string[]{"日","一","二","三","四","五","六"};
p2.setLayout(new GridLayout(6,7));
for(int i=0;i<7;i++)
p2.add(new Label(string[i]));
GregorianCalendar gc=new GregorianCalendar();
gc.set(Year,Mouth,1);
for(int a=0;a<6;a++){
if(str[a]=gc.get(Calender.DAY_OF_WEEK))
break;
}
for(int i=0;i<=a;i++)
p2.add(new Label(" "));
for(int i=0;i<t;i++)
p2.add(new Label(valueOf(i)));
add(p2,"CENTER");
}
}
public static void main(){
MyCalender000 me=new MyCalender000("日历");
me.setSize(300,300);
me.setVisible(true);
}
}
编写日历时出现需要为class,interface或enum的错误
一句注释都没有,完全没心情看下去了
Java在编译时出现错误 :需要Class,interface或enum
错误在第22行public void int() 这个method的名字。int在java中被定义为一种数据类型,所以不可以用来作为method的名字,如楼上所言,正确的method的名字应该是init
编写一个c++程序,要求输入年份月份,并且输入该月的1号为周几,输出该...
include <iostream>class Calendar {public: enum Week { Monday=1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }; enum Month { January=1, February, March, April, May, June, July, August, September, October, November, December }; int year; ...
电脑里常用的的英语有那些(汉语意思)?
第一部分、计算机算法常用术语中英对照 Data Structures 基本数据结构 Dictionaries 字典 Priority Queues 堆 Graph Data Structures 图 Set Data Structures 集合 Kd-Trees 线段树 Numerical Problems 数值问题 Solving Linear Equations 线性方程组 Bandwidth Reduction 带宽压缩 Matrix Multiplication 矩阵乘法 Deter...
Java在编译时出现错误 :需要Class,interface或enum
1.public void int(){ 这句出错了 可能你打算使用代码 public void init(){ 2. 括号范围出错 int searchMonth,searchYear; \/\/查询的年份及月份 }这个括号删除 文件末尾添加} 测试通过