去掉:
package MarathonApp;

解决方案 »

  1.   

    MarathonApp.java:7: MarathonApp.MarathonApp 必须声明为abstract; 它没有在Marath
    onApp.MarathonApp 中定义windowOpened(java.awt.event.WindowEvent)
    public class MarathonApp implements WindowListener
           ^
    1 个错误声明卖windowOpened接口的实现吧
      

  2.   

    这个大概是你想要的
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;public class MarathonApp 
    {
      JLabel label = new JLabel("It just keeps going,and going...");
      JFrame frame = new JFrame("MarathonApp Example");  public MarathonApp()
      {
     
        frame.getContentPane().add (label);
        frame.setSize(300,100);
        frame.setVisible (true);
        frame.addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent e)
    {
             System.exit (0);
          }
    });
       frame.show();
      }
      public static void main(String[] args)
    {
      MarathonApp m = new MarathonApp();
    }}
      

  3.   

    burntorun()大虾,你给的代码确实达到了我的目的,我在此表示感谢,但是我给的代码是书上例子,我只是想知道一下程序错在那儿了
      

  4.   

    基本概念:你的MarathonApp类是从接口WindowListener来的,而接口WindowListener中有多个抽象方法,WindowListener想变成类则每个方法都必须override一下,查JDK1.3 document得到
    interface WindowListener共有7个方法,所以在你的程序中再加入以下6个方法就可以了。
      public void windowOpened(WindowEvent e){  
      }
      public void windowClosed(WindowEvent e){  
      }
      public void windowIconified(WindowEvent e){ 
      }
      public void windowDeiconified(WindowEvent e){
      }
      public void windowActivated(WindowEvent e){
      }
      public void windowDeactivated(WindowEvent e){
      }
    可以查看Thinking in Java(version 1) chapter13的 Using listener adapters for simplicity小节
     ... But since WindowListener is an interface, you must implement all of the other methods even if they don’t do anything. This can be annoying.
    To solve the problem, each of the listener interfaces that have more than one method are provided with adapters,...
      

  5.   

    楼上的大虾,implements 是执行的意思吧,也就是MarathonApp 执行window监听,那我只执行其中的一个方法应该可以吧,还有这个列子是有你说的六个方法,我已经试过不行,我只是为了大家看着清晰才把那六个方法去掉的