Invoked when the Window is set to be the focused Window, which means that the Window, or one of its subcomponents, will receive keyboard events.

解决方案 »

  1.   

    运行这段程序,然后关闭窗口,就会在控制台上显示下面的信息:java.awt.event.WindowEvent[WINDOW_CLOSING,opposite=null,oldState=0,newState=0] on frame0
      

  2.   

    刚才看错了,把下面的程序加进去就好了。 addWindowStateListener(new WindowStateListener(){
    public void windowStateChanged(WindowEvent e){
    System.out.println(e);
    }
    });
      

  3.   

    因为WindowListener类并不捕获windowStateChanged(最大化最小化等)这种事件,所以
    需要将这类事件加入到WindowStateListener中来捕获并进行处理。
    所以上面的代码也可以写成:
                     addWindowStateListener(new WindowWindowAdapter(){
    public void windowStateChanged(WindowEvent e){
    System.out.println(e);
    }
    });
      

  4.   

    new WindowAdapter()谢谢,但是在窗口进行resize的事件怎么捕获进行处理呢?
      

  5.   

    组件的大小变化监听用
    addComponentListener(aComponentListener)