home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / un2maiq4 / pjjava / src / pj / awt / mainframe.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  2.7 KB  |  112 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.     Written by the Personal Journal developers of Dow Jones & Company, Inc.
  4.  
  5.     Dow Jones makes no representations or warranties about 
  6.     the suitability of this software, either express or 
  7.     implied, including but not limited to the implied warranties 
  8.     of merchantability, fitness for a particular purpose, 
  9.     or non-infringement.  Dow Jones will not be liable for 
  10.     any damages suffered by a user as a result of using, 
  11.     modifying or distributing this software or its derivatives.
  12.  
  13.  
  14.  
  15.     @(#)MainFrame.java  0.00 28-Dec-95
  16.  
  17.         A frame that handles WINDOW_DESTROY events.
  18.  
  19.  
  20.     Authors:
  21.  
  22.         rphall   Rick Hall
  23.  
  24.  
  25.     Version Ident:
  26.  
  27.         $Header$
  28.  
  29.  
  30.     History:
  31.  
  32.         0.00 28-Dec-95   rphall  Initial Creation
  33.  
  34. ---------------------------------------------------------------------------*/
  35.  
  36. package pj.awt;
  37.  
  38. import java.awt.Event;
  39. import java.awt.Frame;
  40. import java.lang.String;
  41. import java.lang.System;
  42.  
  43. /**
  44.  *  A frame that handles WINDOW_DESTROY events.
  45.  *  Typically used by applets for "standalone" operation:
  46.  *  <pre>
  47.  *  class SomeApplet extends Applet
  48.  *      {
  49.  *      // ... init, start, paint, and constructor operations
  50.  *      
  51.  *      public static void main(String args[])
  52.  *          {
  53.  *          MainFrame mf = new MainFrame("A frame title");
  54.  *          SomeApplet sa = new SomeApplet();
  55.  *          sa.init();
  56.  *          sa.start();
  57.  *          mf.add(sa);
  58.  *          mf.resize(100,100);
  59.  *          mf.show();
  60.  *      } // main
  61.  *  </pre>
  62.  *
  63.  *  @see        java.awt.Frame
  64.  *  @version    0.00 28-Dec-95
  65.  *  @author     rphall
  66. */
  67. public class MainFrame extends Frame
  68.     {
  69.  
  70.     // --- Public constructors
  71.  
  72.     /**
  73.      *  Construct a MainFrame with no title.
  74.     */
  75.     public MainFrame()
  76.         {       
  77.         super(); 
  78.         }
  79.  
  80.     /**
  81.      *  Construct a MainFrame with a title.
  82.      *  @param title    The title of the frame.
  83.     */
  84.     public MainFrame(String title)
  85.         { 
  86.         super(title); 
  87.         }
  88.  
  89.  
  90.     // --- Public operations
  91.  
  92.     /**
  93.      *  Handle an event.  A MainFrame will handle Event.WINDOW_DESTROY,
  94.      *  and delegate other events to its superclass, Frame.
  95.      *  @param evt      An event targeted at the frame.
  96.      *  @return         True if the frame handled the event, false otherwise.
  97.     */
  98.     public boolean handleEvent(Event evt)
  99.         {
  100.         if (evt.id == Event.WINDOW_DESTROY)
  101.             {
  102.             dispose();
  103.             System.exit(0);
  104.             return true;
  105.             }
  106.         else
  107.             return super.handleEvent(evt);
  108.  
  109.         } // handleEvent
  110.  
  111.     }; // MainFrame
  112.