有一段java程序能够通过编译,但是运行不了,请指教!!

以下一一段程序,能够通过编译,但是无法运行~~!
请高手指点错误之处~~!
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接口的方法吗?而且他只有一个啊~~~!
请问要实现全部接口应该怎么办呢?我是初学者,请指教~~拍手笑清风先生!

你的policeman类实现ActionListener接口,但没有真正实现他的方法!
呵呵,其实很简单,但是却很难发现的,就是你实现的方法,你再仔细看一下就知道了:actiontPerformed 应该是actionPerformed,你多了一个t相当与你自己做了一个方法,而不是实现人家的方法。
这种错误是不应该的啊。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-04-08
楼上正解~
第2个回答  2007-04-08
就这一个类吗 我怎么没有看到main方法呢
没有main方法怎么运行啊
第3个回答  2007-04-08
玫瑰刺心啊, 这可是applet.
相似回答