home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / Gamelication / com / next / gt / WindowDestroyer.java < prev   
Text File  |  1998-04-15  |  590b  |  29 lines

  1. package com.next.gt;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5.  
  6. /**
  7.   Utility class whose objects exit when the attached window is closed.
  8.   */
  9. public class WindowDestroyer extends WindowAdapter {
  10.  
  11.     private Gamelication     owner;
  12.     private Frame        mainScreen;
  13.  
  14.     public WindowDestroyer( Frame gamelicationFrame , Gamelication owner ) {
  15.         mainScreen = gamelicationFrame;
  16.         this.owner = owner;
  17.     }
  18.     
  19.     public void windowClosing(WindowEvent e) {
  20.     if( e.getWindow() == mainScreen ) {
  21.         owner.stop();
  22.         System.exit(0) ;
  23.     }
  24.     else 
  25.         e.getWindow().dispose();
  26.     }
  27. }
  28.  
  29.