Sounds like a job for the setDefaultCloseOperation method of JFrame. You have (I think) 4 options:
Do nothing.hide (which I think is the default behaviour)disposeexit (equivalent to System.exit(0) I think this topic is more appropriate for the Swing forum, so I shall move it.