If you want to run a section of code immediately before your application exits then this article will tell you how to do it. We will be using the WindowClosing event of the main JFrame class of your application. In the Deign View of your application in the project component navigator right click the JFrame Continue Reading …