001    /* PaintEvent.java -- an area of the screen needs to be repainted
002       Copyright (C) 1999, 2002, 2005  Free Software Foundation, Inc.
003    
004    This file is part of GNU Classpath.
005    
006    GNU Classpath is free software; you can redistribute it and/or modify
007    it under the terms of the GNU General Public License as published by
008    the Free Software Foundation; either version 2, or (at your option)
009    any later version.
010    
011    GNU Classpath is distributed in the hope that it will be useful, but
012    WITHOUT ANY WARRANTY; without even the implied warranty of
013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014    General Public License for more details.
015    
016    You should have received a copy of the GNU General Public License
017    along with GNU Classpath; see the file COPYING.  If not, write to the
018    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019    02110-1301 USA.
020    
021    Linking this library statically or dynamically with other modules is
022    making a combined work based on this library.  Thus, the terms and
023    conditions of the GNU General Public License cover the whole
024    combination.
025    
026    As a special exception, the copyright holders of this library give you
027    permission to link this library with independent modules to produce an
028    executable, regardless of the license terms of these independent
029    modules, and to copy and distribute the resulting executable under
030    terms of your choice, provided that you also meet, for each linked
031    independent module, the terms and conditions of the license of that
032    module.  An independent module is a module which is not derived from
033    or based on this library.  If you modify this library, you may extend
034    this exception to your version of the library, but you are not
035    obligated to do so.  If you do not wish to do so, delete this
036    exception statement from your version. */
037    
038    
039    package java.awt.event;
040    
041    import java.awt.Component;
042    import java.awt.Rectangle;
043    
044    /**
045     * This event is generated when an area of the screen needs to be painted.
046     * This event is not meant for users, but exists to allow proper serialization
047     * behavior in the EventQueue with user-accessible events.
048     *
049     * @author Aaron M. Renn (arenn@urbanophile.com)
050     * @since 1.1
051     * @status updated to 1.4
052     */
053    public class PaintEvent extends ComponentEvent
054    {
055      /**
056       * Compatible with JDK 1.1+.
057       */
058      private static final long serialVersionUID = 1267492026433337593L;
059    
060      /** This is the first id in the range of event ids used by this class. */
061      public static final int PAINT_FIRST = 800;
062    
063      /** This is the last id in the range of event ids used by this class. */
064      public static final int PAINT_LAST = 801;
065    
066      /** This id is for paint event types. */
067      public static final int PAINT = 800;
068    
069      /** This id is for update event types. */
070      public static final int UPDATE = 801;
071    
072      /**
073       * This is the rectange to be painted or updated.
074       *
075       * @see #getUpdateRect()
076       * @see #setUpdateRect(Rectangle)
077       * @serial the non-null rectangle to be painted
078       */
079      private Rectangle updateRect;
080    
081      /**
082       * Initializes a new instance of <code>PaintEvent</code> with the specified
083       * source, id, and update region. Note that an invalid id leads to
084       * unspecified results.
085       *
086       * @param source the event source
087       * @param id the event id
088       * @param updateRect the rectangle to repaint
089       * @throws IllegalArgumentException if source is null
090       */
091      public PaintEvent(Component source, int id, Rectangle updateRect)
092      {
093        super(source, id);
094        this.updateRect = updateRect;
095      }
096    
097      /**
098       * Returns the rectange to be updated for this event.
099       *
100       * @return the rectangle to update
101       */
102      public Rectangle getUpdateRect()
103      {
104        return updateRect;
105      }
106    
107      /**
108       * Sets the rectangle to be updated for this event.
109       *
110       * @param updateRect the new update rectangle for this event
111       */
112      public void setUpdateRect(Rectangle updateRect)
113      {
114        this.updateRect = updateRect;
115      }
116    
117      /**
118       * Returns a string identifying this event.
119       *
120       * @return a string identifying this event
121       */
122      public String paramString()
123      {
124        return (id == PAINT ? "PAINT,updateRect=" : id == UPDATE
125                ? "UPDATE,updateRect=" : "unknown type,updateRect=") + updateRect;
126      }
127    } // class PaintEvent