日期:2014-05-20  浏览次数:20721 次

Swing中WindowConstants.EXIT_ON_CLOSE和EXIT_ON_CLOSE直接写有什么区别?
菜鸟求教:

Swing中setDefaultCloseOperation()方法的参数,
用WindowConstants.EXIT_ON_CLOSE和用直接用EXIT_ON_CLOSE有什么区别?

------解决方案--------------------
没区别,都是调的WindowConstants.EXIT_ON_CLOSE,可以直接写EXIT_ON_CLOSE是因为它实现了WindowConstants接口
------解决方案--------------------
在早期的时候一般是写WindowConstants.EXIT_ON_CLOSE,它实现了关闭,
但是在JDK升级以后,WindowConstants接口中有EXIT_ON_CLOSE实现的类,所以可以写成EXIT_ON_CLOSE也就直接实现了WindowConstants.EXIT_ON_CLOSE