home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / PaintEvent.java < prev    next >
Text File  |  1997-05-20  |  3KB  |  114 lines

  1. /*
  2.  * @(#)PaintEvent.java    1.6 97/02/20
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.awt.event;
  24.  
  25. import java.awt.Component;
  26. import java.awt.Event;
  27. import java.awt.Rectangle;
  28.  
  29. /**
  30.  * The component-level paint event.
  31.  * This event is a special type which is used to ensure that
  32.  * paint/update method calls are serialized along with the other
  33.  * events delivered from the event queue.  This event is not
  34.  * designed to be used with the Event Listener model; programs
  35.  * should continue to override paint/update methods in order
  36.  * render themselves properly.
  37.  *
  38.  * @version 1.6 02/20/97
  39.  * @author Amy Fowler
  40.  */
  41. public class PaintEvent extends ComponentEvent {
  42.  
  43.     /**
  44.      * Marks the first integer id for the range of paint event ids.
  45.      */    
  46.     public static final int PAINT_FIRST        = 800;
  47.  
  48.     /**
  49.      * Marks the last integer id for the range of paint event ids.
  50.      */
  51.     public static final int PAINT_LAST        = 801;
  52.  
  53.     /**
  54.      * The paint event type.  
  55.      */
  56.     public static final int PAINT = PAINT_FIRST;
  57.  
  58.     /**
  59.      * The update event type.  
  60.      */
  61.     public static final int UPDATE = PAINT_FIRST + 1; //801
  62.  
  63.     Rectangle updateRect;
  64.  
  65.     /*
  66.      * JDK 1.1 serialVersionUID 
  67.      */
  68.     private static final long serialVersionUID = 1267492026433337593L;
  69.  
  70.     /**
  71.      * Constructs a PaintEvent object with the specified source component
  72.      * and type.
  73.      * @param source the object where the event originated
  74.      * @id the event type
  75.      * @updateRect the rectangle area which needs to be repainted
  76.      */
  77.     public PaintEvent(Component source, int id, Rectangle updateRect) {
  78.         super(source, id);
  79.         this.updateRect = updateRect;
  80.     }
  81.  
  82.     /**
  83.      * Returns the rectangle representing the area which needs to be
  84.      * repainted in response to this event.
  85.      */
  86.     public Rectangle getUpdateRect() {
  87.         return updateRect;
  88.     }
  89.  
  90.     /**
  91.      * Sets the rectangle representing the area which needs to be
  92.      * repainted in response to this event.
  93.      * @param updateRect the rectangle area which needs to be repainted
  94.      */
  95.     public void setUpdateRect(Rectangle updateRect) {
  96.         this.updateRect = updateRect;
  97.     }
  98.  
  99.     public String paramString() {
  100.         String typeStr;
  101.         switch(id) {
  102.           case PAINT:
  103.               typeStr = "PAINT";
  104.               break;
  105.           case UPDATE:
  106.               typeStr = "UPDATE";
  107.               break;
  108.           default:
  109.               typeStr = "unknown type";
  110.         }
  111.         return typeStr + ",updateRect="+(updateRect != null ? updateRect.toString() : "null");
  112.     }
  113. }
  114.