以下一一段程序,能够通过编译,但是无法运行~~!
请高手指点错误之处~~!
import java.applet.*;import java.awt.*;import java.awt.event.*;
public class example9_3 extends Applet implements ActionListener
{
TextField text1,text2,text3;
policeman police;
public void init()
{
text1=new TextField(10);text2=new TextField(10);text3=new TextField(10);
police=new policeman(this);
add(text1);add(text2);add(text3);
text1.addActionListener(this);text1.addActionListener(police);
}
public void actionPerformed(ActionEvent e)
{
String a1=e.getActionCommand();
int c=Integer.parseInt(a1);
int b=c*c;text2.setText(c+"的平方是:"+b);
}
}
class policeman implements ActionListener
{
example9_3 a=null;
policeman(example9_3 a)
{
this.a=a;
}
public void actiontPerformed(ActionEvent e)
{
String s=e.getActionCommand();
int c=Integer.parseInt(s);
int b=c*c*c;a.text3.setText(c+"的立方是:"+b);
}
}
actionPerformed(ActionEvent e)不就是ActionListener接口的方法吗?而且他只有一个啊~~~!
请问要实现全部接口应该怎么办呢?我是初学者,请指教~~拍手笑清风先生!