JFrame On Close Operation

java, jframe, swing, user-interface, windowlistener

Solution

You might be interested in using a `WindowListener`. The `WindowListener` tutorial.

Problem

I was wondering if there is a way, by clicking on the "X", to let the program perform some code before closing the JFrame. The `setDefaultCloseOperation()` method takes only an integer. ``` setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ```

Original source