I have made an application and i need to save some options before exit.(something like window dimension, ..., that will be written in a file.)
The main frame has set
You may register a WindowListener and save your options in the windowClose method.
And of course
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);