GUI not killing processes when X is used to exit
I used netbeans to help develop a GUI application. Everything exits great when the users uses the FILE - EXIT menu option. However, in windows there is an X in the upper righthand corner of the frame that can be used to exit an application. When the user uses that exit method the java process doesn't get killed. The GUI disappears but the java.exe process in the task manager stays on and the cleanup of some files that were created doesn't take place.
Here is my code for the file - exit menu option:
Code:
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
// seq1Dialog.dispose();
// seq2Dialog.dispose();
File f1 = new File(System.getProperty("user.home")+System.getProperty("file.separator")+"lines.txt");
File f2 = new File(System.getProperty("user.home")+System.getProperty("file.separator")+"pairings.txt");
File f3 = new File(System.getProperty("user.home")+System.getProperty("file.separator")+"Eqps.txt");
boolean successfullinesdelete = f1.delete();
boolean successfulpairingsdelete = f2.delete();
boolean successfuleqpdelete = f3.delete();
if (!(successfuleqpdelete && successfullinesdelete && successfulpairingsdelete)){
System.out.println("Deletion failed. Check files");
System.exit(0);
}else{
System.out.println("All Bidit Files deleted.");
}
System.exit(0);// TODO add your handling code here:
}
Do I need to do something more to tie the windows generated X button in the FRAME to the exit method?