home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / event / WindowEvent.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  5.1 KB  |  159 lines

  1. /*
  2.  * @(#)WindowEvent.java    1.14 98/03/18
  3.  *
  4.  * Copyright 1996, 1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.event;
  16.  
  17. import java.awt.Event;
  18. import java.awt.Window;
  19.  
  20. /**
  21.  * A low-level event which indicates that a window has changed its status.
  22.  * This low-level event is generated by a Window object when it is opened,
  23.  * closed, about to close, activated or deactivated, iconified or deconified.
  24.  * <P> 
  25.  * The event is passed to every <code>WindowListener</code>
  26.  * or <code>WindowAdapter</code> object which registered to receive such
  27.  * events using the window's <code>addWindowListener</code> method.
  28.  * (<code>WindowAdapter</code> objects implement the 
  29.  * <code>WindowListener</code> interface.) Each such listener object 
  30.  * gets this <code>WindowEvent</code> when the event occurs.
  31.  *
  32.  * @see WindowAdapter
  33.  * @see WindowListener
  34.  * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/windowlistener.html">Tutorial: Writing a Window Listener</a>
  35.  * @see <a href="http://www.awl.com/cp/javaseries/jcl1_2.html">Reference: The Java Class Libraries (update file)</a>
  36.  *
  37.  * @version 1.14 03/18/98
  38.  * @author Carl Quinn
  39.  * @author Amy Fowler
  40.  */
  41. public class WindowEvent extends ComponentEvent {
  42.  
  43.     /**
  44.      * The first number in the range of ids used for window events.
  45.      */
  46.     public static final int WINDOW_FIRST        = 200;
  47.  
  48.     /**
  49.      * The last number in the range of ids used for window events.
  50.      */
  51.     public static final int WINDOW_LAST         = 206;
  52.  
  53.     /**
  54.      * The window opened event.  This event is delivered only
  55.      * the first time a window is made visible.
  56.      */
  57.     public static final int WINDOW_OPENED    = WINDOW_FIRST; // 200
  58.  
  59.     /**
  60.      * The "window is closing" event. This event is delivered when
  61.      * the user selects "Quit" from the window's system menu.  If
  62.      * the program does not explicitly hide or destroy the window as
  63.      * while processing this event, the window close operation will be
  64.      * cancelled.
  65.      */
  66.     public static final int WINDOW_CLOSING    = 1 + WINDOW_FIRST; //Event.WINDOW_DESTROY
  67.  
  68.     /**
  69.      * The window closed event. This event is delivered after
  70.      * the window has been closed as the result of a call to hide or
  71.      * destroy.
  72.      */
  73.     public static final int WINDOW_CLOSED    = 2 + WINDOW_FIRST;
  74.  
  75.     /**
  76.      * The window iconified event. This event indicates that the window
  77.      * was shrunk down to a small icon.
  78.      */
  79.     public static final int WINDOW_ICONIFIED    = 3 + WINDOW_FIRST; //Event.WINDOW_ICONIFY
  80.  
  81.     /**
  82.      * The window deiconified event type. This event indicates that the
  83.      * window has been restored to its normal size.
  84.      */
  85.     public static final int WINDOW_DEICONIFIED    = 4 + WINDOW_FIRST; //Event.WINDOW_DEICONIFY
  86.  
  87.     /**
  88.      * The window activated event type. This event indicates that keystrokes
  89.      * and mouse clicks are directed towards this window.
  90.      */
  91.     public static final int WINDOW_ACTIVATED    = 5 + WINDOW_FIRST;
  92.  
  93.     /**
  94.      * The window deactivated event type. This event indicates that keystrokes
  95.      * and mouse clicks are no longer directed to the window.
  96.      */
  97.     public static final int WINDOW_DEACTIVATED    = 6 + WINDOW_FIRST;
  98.  
  99.     /*
  100.      * JDK 1.1 serialVersionUID 
  101.      */
  102.      private static final long serialVersionUID = -1567959133147912127L;
  103.  
  104.     /**
  105.      * Constructs a WindowEvent object.
  106.      * @param source the Window object that originated the event
  107.      * @param id     an integer indicating the type of event
  108.      */
  109.     public WindowEvent(Window source, int id) {
  110.         super(source, id);
  111.     }
  112.  
  113.     /**
  114.      * Returns the originator of the event.
  115.      *
  116.      * @return the Window object that originated the event
  117.      */
  118.     public Window getWindow() {
  119.         return (source instanceof Window) ? (Window)source : null;
  120.     } 
  121.  
  122.     /**
  123.      * Returns a parameter string identifying this event.
  124.      * This method is useful for event-logging and for debugging.
  125.      *
  126.      * @return a string identifying the event and its attributes
  127.      */
  128.     public String paramString() {
  129.         String typeStr;
  130.         switch(id) {
  131.           case WINDOW_OPENED:
  132.               typeStr = "WINDOW_OPENED";
  133.               break;
  134.           case WINDOW_CLOSING:
  135.               typeStr = "WINDOW_CLOSING";
  136.               break;
  137.           case WINDOW_CLOSED:
  138.               typeStr = "WINDOW_CLOSED";
  139.               break;
  140.           case WINDOW_ICONIFIED:
  141.               typeStr = "WINDOW_ICONIFIED";
  142.               break;
  143.           case WINDOW_DEICONIFIED:
  144.               typeStr = "WINDOW_DEICONIFIED";
  145.               break;
  146.           case WINDOW_ACTIVATED:
  147.               typeStr = "WINDOW_ACTIVATED";
  148.               break;
  149.           case WINDOW_DEACTIVATED:
  150.               typeStr = "WINDOW_DEACTIVATED";
  151.               break;
  152.           default:
  153.               typeStr = "unknown type";
  154.         }
  155.         return typeStr;
  156.     }
  157.  
  158. }
  159.