Save This Page
Home » openjdk-7 » java » awt » event » [javadoc | source]
    1   /*
    2    * Copyright 1996-2007 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package java.awt.event;
   27   
   28   import java.awt.Component;
   29   import java.awt.Rectangle;
   30   
   31   /**
   32    * The component-level paint event.
   33    * This event is a special type which is used to ensure that
   34    * paint/update method calls are serialized along with the other
   35    * events delivered from the event queue.  This event is not
   36    * designed to be used with the Event Listener model; programs
   37    * should continue to override paint/update methods in order
   38    * render themselves properly.
   39    * <p>
   40    * An unspecified behavior will be caused if the {@code id} parameter
   41    * of any particular {@code PaintEvent} instance is not
   42    * in the range from {@code PAINT_FIRST} to {@code PAINT_LAST}.
   43    *
   44    * @author Amy Fowler
   45    * @since 1.1
   46    */
   47   public class PaintEvent extends ComponentEvent {
   48   
   49       /**
   50        * Marks the first integer id for the range of paint event ids.
   51        */
   52       public static final int PAINT_FIRST         = 800;
   53   
   54       /**
   55        * Marks the last integer id for the range of paint event ids.
   56        */
   57       public static final int PAINT_LAST          = 801;
   58   
   59       /**
   60        * The paint event type.
   61        */
   62       public static final int PAINT = PAINT_FIRST;
   63   
   64       /**
   65        * The update event type.
   66        */
   67       public static final int UPDATE = PAINT_FIRST + 1; //801
   68   
   69       /**
   70        * This is the rectangle that represents the area on the source
   71        * component that requires a repaint.
   72        * This rectangle should be non null.
   73        *
   74        * @serial
   75        * @see java.awt.Rectangle
   76        * @see #setUpdateRect(Rectangle)
   77        * @see #getUpdateRect()
   78        */
   79       Rectangle updateRect;
   80   
   81       /*
   82        * JDK 1.1 serialVersionUID
   83        */
   84       private static final long serialVersionUID = 1267492026433337593L;
   85   
   86       /**
   87        * Constructs a <code>PaintEvent</code> object with the specified
   88        * source component and type.
   89        * <p> This method throws an
   90        * <code>IllegalArgumentException</code> if <code>source</code>
   91        * is <code>null</code>.
   92        *
   93        * @param source     The object where the event originated
   94        * @param id           The integer that identifies the event type.
   95        *                     For information on allowable values, see
   96        *                     the class description for {@link PaintEvent}
   97        * @param updateRect The rectangle area which needs to be repainted
   98        * @throws IllegalArgumentException if <code>source</code> is null
   99        * @see #getSource()
  100        * @see #getID()
  101        * @see #getUpdateRect()
  102        */
  103       public PaintEvent(Component source, int id, Rectangle updateRect) {
  104           super(source, id);
  105           this.updateRect = updateRect;
  106       }
  107   
  108       /**
  109        * Returns the rectangle representing the area which needs to be
  110        * repainted in response to this event.
  111        */
  112       public Rectangle getUpdateRect() {
  113           return updateRect;
  114       }
  115   
  116       /**
  117        * Sets the rectangle representing the area which needs to be
  118        * repainted in response to this event.
  119        * @param updateRect the rectangle area which needs to be repainted
  120        */
  121       public void setUpdateRect(Rectangle updateRect) {
  122           this.updateRect = updateRect;
  123       }
  124   
  125       public String paramString() {
  126           String typeStr;
  127           switch(id) {
  128             case PAINT:
  129                 typeStr = "PAINT";
  130                 break;
  131             case UPDATE:
  132                 typeStr = "UPDATE";
  133                 break;
  134             default:
  135                 typeStr = "unknown type";
  136           }
  137           return typeStr + ",updateRect="+(updateRect != null ? updateRect.toString() : "null");
  138       }
  139   }

Save This Page
Home » openjdk-7 » java » awt » event » [javadoc | source]