请问java 中的Swing包JFrame类中setDefaultCloseOperation(int operation)方法中的两个参数DISPOSE_ON_CLOSE(单击后窗口释放)和EXIT_ON_CLOSE(单击后窗口关闭)有什么区别呢?我编写了一个程序试了一下,它们的功能好像一样,都可以使窗口关闭,但窗口释放是什么意思呢?
谢谢!

解决方案 »

  1.   

    自己看JDK API,上面讲得很清楚。DISPOSE_ON_CLOSE,自动隐藏并释放该窗体。如果是程序的最后一个窗体被关闭,整个程序就挂了;如果是程序的一个子窗体,关闭后仍可通过调用该窗体对象的setVisible(true)重新显示之。EXIT_ON_CLOSE,仅在应用程序中使用,即不用于程序的子窗体。关闭窗体,整个程序就挂了。
      

  2.   

    api中写的看不懂么?
        DO_NOTHING_ON_CLOSE (defined in WindowConstants): Don't do anything; require the program to handle the operation in the windowClosing method of a registered WindowListener object.
        HIDE_ON_CLOSE (defined in WindowConstants): Automatically hide the frame after invoking any registered WindowListener objects.
        DISPOSE_ON_CLOSE (defined in WindowConstants): Automatically hide and dispose the frame after invoking any registered WindowListener objects.
        EXIT_ON_CLOSE (defined in JFrame): Exit the application using the System exit method. Use this only in applications. 
      

  3.   

    谢谢两位高手,我懂了,不好意思,我把API这个有用的文档忘记了,谢谢你们的提醒,谢谢了!