id on ' tgethowcaniemploythiscode :
frame.setdefaultcloseoperation (jframe.exit _ on _ close );
to close the program with the x button。
解决方案
You need the line
frame.setdefaultcloseoperation (window constants.exit _ on _ close );
becausethedefaultbehaviourthejframewhenyoupressthexbuttonistheequivalentto
frame.setdefaultcloseoperation (window constants.hide _ on _ close );
soalmostallthetimesyou ' llneedtoaddthatlinemanuallywhencreatingyourjframe
iamcurrentlyreferringtoconstantsinwindowconstantslikewindowconstants.exit _ on _ closeinsteadofthesameconstantsdeclantsdeclaclantsdcleclantsdeclantsdecleclantsdecleclantsclan