下面这个程序那里有问题?
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
class MyLabel extends Label
{ Label l1,l2,l3,l4,l5;
Panel panel;
GridBagLayout gl ;
GridBagConstraints c ;
MyLabel(Container con)
{
gl=new GridBagLayout();
c=new GridBagConstraints();
panel.setLayout(gl);
panel=new Panel();
con.add(panel);
l1=new Label(" 1");
l2=new Label(" 2");
l3=new Label(" 3");
l4=new Label(" 4");
l5=new Label(" 5");
c.gridx = 0;
c.gridy = 0;
gl.setConstraints(l1, c);
panel.add(l1);
c.gridx = 0;
c.gridy = 1;
gl.setConstraints(l2, c);
panel.add(l2);
c.gridx = 0;
c.gridy = 2;
gl.setConstraints(l3, c);
panel.add(l3);
c.gridx = 0;
c.gridy = 3;
gl.setConstraints(l4, c);
panel.add(l4);
c.gridx = 0;
c.gridy = 4;
gl.setConstraints(l5, c);
panel.add(l5);
}
}
public class Zuoye10_4 extends Applet
{
MyLabel lab;
public void init()
{
lab=new MyLabel(this);
add(lab);
}
}
----------------解决方案--------------------------------------------------------