|
|

|  |
Closing the main window and stopping the program When the user indicates that the program is to exit, it should shut down gracefully. By convention there are at least two ways for the user to do this: The program can be terminated (stopped) by the sending of a System.exit() message. This will work whatever the program was doing at the time. A well-designed program should tidy up before it does this. In many cases the program should ask the user if it is okay to close. For example, if you are editing a document in a word processor and click on the close button, and there are some changes made since the last change, the word processor should ask if you want to save the work first. If stopping the program is uncomplicated no files to save, for example it can simply call System.exit() from within windowClosing() . So the windowClosing() method would look as follows: public void windowClosing (WindowEvent e) { // terminate program System.exit(0); } Back to top 
RITSEC - Global Campus Copyright ?1999 RITSEC- Middlesex University. All rights reserved. webmaster@globalcampus.com.eg |
|