//boy.javaimportjava.util.*;importjava.awt.*;importjava.awt.event.*;importjava.applet.*;publicclassBoyextendsAppletimplementsActionListener{Labela[]=newLabel[42];Buttonti...
//boy.java
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Boy extends Applet implements ActionListener
{
Label a[]=new Label[42];
Button titleName[]=new Button[7];
String name[]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
Button nextMonth,previousMonth;
int i,year=2005,month=1;
CalendarBean calendar;
Laber showMessage=new Label("",Label.center);
Public void main()
{
super ("小程序查看器:Boy.class");
int hgap=5,vap=5;
setLayout(new BorderLayout(5,5));
//[代码1]将Java Applet的布局设置为BorderLayout布局
Panel pCenter=new Panel();
pCenter.setLayout(new GridLayout(7,7));
//[代码2]将pCenter的布局设置为7行7列的GridLayout布局
for (int i=0;i<7;i++)
{
titleName[i]=new Button(name[i]);
pCenter.add(new Button(titleName[i]));
// [代码3] pCenter添加组件titleName[i]
}
for (int i=0;i<42;i++)
{
a[i]=new Label(" ",Label.CENTER);
pCenter.add(new Button(a[i]));
//[代码3]pCenter添加组件a[i]
}
Calendar=new CalendarBean();
year=2005;
calendar.setYear(year);
calendar.setMonth(month);
String day[]=calendar.getCalendar();
for(int i=0;i<42;i++)
{
a[i].setText(day[i]);
}
nextMonth=new Button("下月");
nextMonth.addActionListener(this);
Panel pNorth=new Panel();
pSorth=new Panel();
pNorth.add(previousMonth);
pNorth.add(nextMonth);
pSorth.add(showMessage);
showMessage.setText("日历:"+calendar.getYear()+"年"+calendar.getMonth()+"月");
ScrollPane scrollPane=new ScrollPane();
scrollPane.add(pCenter);
BtnC=new Button(scrollPane);
add (scrollPane,Btnc);
//[代码5]将Java Applet添加scrollPane在中心区域
BtnN=new Button(pNorth);
add (pNorth,Btnc);
//[代码6]将Java Applet添加pMonth在中心区域
BtnS=new Button(pSouth);
add (pSouth,BtnS);
//[代码7]将Java Applet添加pSouth在中心区域
}
后面还有接着的。。帮我看看拿哪错了
展开