一个小问题,哪里出错了
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Exam_9 extends Applet implements ActionListener
{
Button left,center,right;
public void init()
{
left=new Button("左对齐");
left.addActionListener(this);
add(left);
center=new Button("居中");
center.addActionListener(this);
add(center);
right=new Button("右对齐");
right.addActionListener(this);
add(right);
}
public void actionPerformed(ActionEvent e)
{
int align=FlowLayout.LEFT;
if(e.getSource==left)
align=FlowLayout.LEFT;
else if(e.getSource==right)
align=FlowLayout.RIGHT;
else if(e.getSource==center)
align=FlowLayout.CENTER;
setLayout(new FlowLayout(align));
validate();
}
}