import java.awt.event.*;
import java.awt.*;
public class ww
{
  public static void main(String[] args) 
 { 
       Button b = new Button("Press Me!");
       b.addActionListener(new ButtonHandler());
       b.setVisible(true);
 } 

class ButtonHandler extends ActionListener
{
public void PerFormed(ActionEven e)
{
System.out.println("Action occurred");
}
}

解决方案 »

  1.   

    这里写的错了:"public void PerFormed(ActionEven e) "应该为public void  actionPerformed(ActionEvent e) 
      

  2.   

    注意: 编写程序的习惯,哪有方法名以大写字母开头的?哪有类名以小写字母开头的?(习惯)
    3。 Camel标记法:首字母是小写的,接下来的单词都以大写字母开头
    4。 Pascal标记法:首字母是大写的,接下来的单词都以大写字母开头
    5。 匈牙利类型标记法: 在Pascal标记法前加一个小写字母或者小写字母序列,以说明该变量的类型。(约定表)
      

  3.   

    Error 1:ActionEven cannot be resolved to a type     (Line 15)
            这是因为你掉了一个 't' , 应该是 "ActionEvent" Error 2:
    The method addActionListener(ActionListener) in the type Button is not applicable for the arguments (ButtonHandler) Error 3:
    The type ActionListener cannot be the superclass of ButtonHandler; a superclass must be a class
    这是因为 "ActionListener" 是一个接口,而不是一个类,所以不能进行继承。
    你这代码本身就有问题的,你可以想一下,一个 Button 应该要装载到一个容器中才能显示出来吧?
    可以参考以下代码:
    import java.awt.event.*;
    import java.awt.*;public class ww {
    public static void main(String[] args) {
    Frame f = new Frame("MyFrame");
    f.setBounds(0, 0, 200, 200);
    Button b = new Button("Press Me!");
    b.addActionListener(new ButtonHandler());
    f.add(b);
    f.show();
    }
    }class ButtonHandler implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub
    System.out.println("Action occurred");
    }
    }