public void addWindowListener(WindowListener l)这个函数的参数应该是WindowListener,你用的是Frame,当然不行了。呵呵……

解决方案 »

  1.   

    addWindowListener(WindowListener l) Parameters: l - the window listener参数不对,不能用frame做参数。
      

  2.   

    frObj.addWindowListener(this);
    也不行
      

  3.   

    用frObj.addWindowListener(this);那类firstapp要扩展Listener。
      

  4.   

    能不能举个例子说说Java事件的用法
      

  5.   

    一个简单例子。相信对你有帮助。//: JButtonDemo.java
    // Looks like Java 1.1 but with J's added
    package c13.swing;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;public class JButtonDemo extends Applet {
    static boolean t=true;
      JButton 
        b1 = new JButton("JButton 1"),
        b2 = new JButton("JButton 2");
      JTextArea t = new JTextArea();
      public void init() {
        ActionListener al = new ActionListener() {
          public void actionPerformed(ActionEvent e){
            String name = 
              ((JButton)e.getSource()).getText();
            t.setText(name + "\n Pressed");
          }
        };
        b1.addActionListener(al);
        add(b1);
        b2.addActionListener(al);
        add(b2);
        add(t);
      }
      public static void main(String args[]) {
        JButtonDemo applet = new JButtonDemo();
        JFrame frame = new JFrame("TextAreaNew");
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e){
            System.exit(0);
          }
        });
        frame.getContentPane().add(
          applet, BorderLayout.CENTER);
        frame.setSize(300,100);
        applet.init();
        applet.start();
        frame.setVisible(true);
      }
    } ///:~