per far si che la chiusura della finestra termini anke l'applicazione:
codice:
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);