Cardlayout布局管理器编译问题
源代码:import java.awt.*;
import java.awt.event.*;
public class AWT04 extends Frame {
Panel p=new Panel();
Button af=new Button("the first");
Button al=new Button("the last");
Button an=new Button("next");
Button ap=new Button("previous");
Button ag=new Button("search");
TextField bf=new TextField();
CardLayout c1=new CardLayout();
AWT04(){
this.setTitle("CardLayout 布局 ");
this.setLayout(null);
this.add(p);
p.setLayout(c1);
for(int j=1;j<=10;j++){
Button atemp=new Button("Button"+j);
p.add(atemp,""+j);
}
p.setBounds(10,40,100,100);
this.add(af);
af.addActionListener((ActionListener) this);
af.setBounds(120,40,60,20);
this.add(al);
al.addActionListener((ActionListener) this);
al.setBounds(120,40,60,20);
this.add(an);
an.addActionListener((ActionListener) this);
an.setBounds(120,40,60,20);
this.add(ap);
ap.addActionListener((ActionListener) this);
ap.setBounds(120,40,60,20);
this.add(ag);
ag.addActionListener((ActionListener) this);
ag.setBounds(120,40,60,20);
this.add(bf);
bf.setBounds(20,160,40,20);
this.setBounds(200,200,400,380);
this.setVisible(true);
}
public void actionPerformed(java.awt.event.ActionEvent e){
if(e.getSource()==an){
c1.next(p);
}
if(e.getSource()==ap){
c1.previous(p);
}
if(e.getSource()==af){
c1.first(p);
}
if(e.getSource()==al){
c1.last(p);
}
if(e.getSource()==ag){
c1.show(p,af.getText().trim());
(af.setText("");
}
}
public static void main(String[]args){
new AWT04();
}
}
//在eclipse编译的时候出错,无法输出。红色字体为程序报错的地方。希望得到解答。