JFrame exit on close

Advertisement
a) setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b) addWindowListener(new WindowAdapter(){
     public void windowClosing(WindowEvent e)
{System.exit(0);}
which one is better ? or are they both exactly the same ?
Advertisement

Replay

i prefere the WindowListener, because I can write my own code, when closing. Like: Bye-Messages, memory clean up, connection closing, ...
woodi