Disable the Window close button on JFrame

How to disable the Window close button (the top right corner x button) on JFrame, I would like to close application from menu.
ahTriAsked:
Who is Participating?
 
jimmackCommented:
JFrame myFrame = new JFrame("A Frame");

myFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
0
 
ahTriAuthor Commented:
Cool, that's partly work now, however the button is not disable, so user still can click it, and they will question "why it's not closed when I click on the button?"
0
 
ahTriAuthor Commented:
I got it work out, thanks
0
 
jimmackCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.