你这里是写在一起的吗?如果是的话!  那就错误太多了
首先 import 必须写在程序上面!如果有package 就跟在他的后面!如果是写在2个程序里的话!
import ButtonHandler 就是不对的!我觉得你还有说明白!

解决方案 »

  1.   

    而且我把import ButtonHandler放在上面的话。好像也不能编译。它说import ButtonHandler是有问题的。
      

  2.   

    ButtonHandler是你自己写的吧?不用import,直接放在同一文件目录下就行了
      

  3.   

    我已经给你的程序修改好了! 在我的机器上可以跑了! 你自己试试吧!import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ActionListener;  public class TextButton extends Frame{
          public static void main(String arg[]){
             Frame f      = new Frame("Test");
             Button b     = new Button("Press Me!");
             b.addActionListener(new ButtonHandler());
             f.setLayout(new FlowLayout());
             f.add(b);
             f.setSize(200,100);
             f.setVisible(true);
             f.addWindowListener(new WindowAdapter(){
             public void windowClosing(WindowEvent e){
                 System.exit(0);
               }
             });
         }
      }class ButtonHandler implements ActionListener{
        public void actionPerformed(ActionEvent e){
           System.out.println("Action occurred");   
           }
    }