1
mainGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Intellij Code Analysis:

Warning:(33, 46) Must be one of: WindowConstants.DO_NOTHING_ON_CLOSE, WindowConstants.HIDE_ON_CLOSE, WindowConstants.DISPOSE_ON_CLOSE, WindowConstants.EXIT_ON_CLOSE

SO,is it better to use WindowConstants.EXIT_ON_CLOSE rather than JFrame.EXIT_ON_CLOSE?

Why?

guo
  • 9,674
  • 9
  • 41
  • 79

1 Answers1

1

The two choices are the same.As you can see the method setDefaultCloseOperation() takes as a parameter an integer value so if you passed WindowConstants.DISPOSE_ON_CLOSE or JFrame.DISPOSE_ON_CLOSE it's the same.

SlaimanK
  • 31
  • 2