Java - how do I prevent WindowClosing from actually closing the window

后端 未结 7 1673
灰色年华
灰色年华 2020-12-03 04:23

I seem to have the reverse problem to most people. I have the following pretty standard code to see if the user wants to do some saves before closing the window:

         


        
7条回答
  •  萌比男神i
    2020-12-03 04:39

    This is the key, methinks: frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); Makes the difference in the test case I cooked up.

提交回复
热议问题