home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / enxle1f6 / src / games / battle / client / clientapplet / clientframe.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.1 KB  |  50 lines

  1. /*
  2.  * @(#)ClientFrame.java
  3.  */
  4. package games.Battle.client.ClientApplet;
  5.  
  6. import java.awt.Frame;
  7. import java.awt.Event;
  8.  
  9. /**
  10.  * The ClientFrame is a Frame which recognizes WINDOW_DESTROY
  11.  * events and processes them in a way friendly to an executing
  12.  * ClientApplet.
  13.  *
  14.  * @author Alex Nicolaou
  15.  * @author Jay Steele
  16.  */
  17. public class ClientFrame extends Frame {
  18.  
  19.     /**
  20.      * The game applet this frame will be "holding".
  21.      */
  22.     ClientApplet gameApplet;
  23.  
  24.     /**
  25.      * Construct a ClientFrame with the given title and containing 
  26.      * the given applet. If the frame is Closed, the applet is
  27.      * destroyed.
  28.      * @param title the title for the frame
  29.      * @param applet the ClientApplet to destroy on a CLOSE_WINDOW event
  30.      * @see ClientApplet
  31.      */
  32.     public ClientFrame(String title, ClientApplet applet) {
  33.         super(title);
  34.         gameApplet = applet;
  35.     }
  36.  
  37.     /**
  38.      * Process events from the frame.
  39.      * @param e an event
  40.      */
  41.     public boolean handleEvent(Event e) {
  42.         if (e.id == Event.WINDOW_DESTROY) {
  43.             gameApplet.destroy();
  44.             dispose();
  45.             return true;
  46.         }
  47.         return super.handleEvent(e);
  48.     }
  49. }
  50.