【问题标题】:WindowConstants.EXIT_ON_CLOSE vs JFrame.EXIT_ON_CLOSE [duplicate]WindowConstants.EXIT_ON_CLOSE 与 JFrame.EXIT_ON_CLOSE [重复]
【发布时间】:2016-01-30 04:37:22
【问题描述】:
mainGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Intellij 代码分析:

警告:(33, 46) 必须是以下之一:WindowConstants.DO_NOTHING_ON_CLOSE, WindowConstants.HIDE_ON_CLOSE,WindowConstants.DISPOSE_ON_CLOSE, WindowConstants.EXIT_ON_CLOSE

那么,使用WindowConstants.EXIT_ON_CLOSE 比使用JFrame.EXIT_ON_CLOSE 更好吗?

为什么?

【问题讨论】:

  • 检查this链接,看看是否有帮助。
  • JFrame 实现WindowConstants

标签: java swing intellij-idea jframe


【解决方案1】:

这两个选项是相同的。正如您所见,setDefaultCloseOperation() 方法将整数值作为参数,因此如果您传递 WindowConstants.DISPOSE_ON_CLOSE 或 JFrame.DISPOSE_ON_CLOSE,则它是相同的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-15
    • 2015-02-17
    • 2011-10-26
    • 2013-02-24
    • 2020-10-30
    • 2013-07-16
    • 2012-10-22
    相关资源
    最近更新 更多