001: /*
002: * @(#)PaintEvent.java 1.16 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program 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 version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package java.awt.event;
029:
030: import java.awt.Component;
031: import java.awt.Rectangle;
032:
033: /**
034: * The component-level paint event.
035: * This event is a special type which is used to ensure that
036: * paint/update method calls are serialized along with the other
037: * events delivered from the event queue. This event is not
038: * designed to be used with the Event Listener model; programs
039: * should continue to override paint/update methods in order
040: * render themselves properly.
041: *
042: * @version 1.12 08/19/02
043: * @author Amy Fowler
044: */
045: public class PaintEvent extends ComponentEvent {
046: /**
047: * Marks the first integer id for the range of paint event ids.
048: */
049: public static final int PAINT_FIRST = 800;
050: /**
051: * Marks the last integer id for the range of paint event ids.
052: */
053: public static final int PAINT_LAST = 801;
054: /**
055: * The paint event type.
056: */
057: public static final int PAINT = PAINT_FIRST;
058: /**
059: * The update event type.
060: */
061: public static final int UPDATE = PAINT_FIRST + 1; //801
062: Rectangle updateRect;
063: /*
064: * JDK 1.1 serialVersionUID
065: */
066: private static final long serialVersionUID = 1267492026433337593L;
067:
068: /**
069: * Constructs a PaintEvent object with the specified source component
070: * and type.
071: * @param source the object where the event originated
072: * @id the event type
073: * @updateRect the rectangle area which needs to be repainted
074: */
075: public PaintEvent(Component source, int id, Rectangle updateRect) {
076: super (source, id);
077: this .updateRect = updateRect;
078: }
079:
080: /**
081: * Returns the rectangle representing the area which needs to be
082: * repainted in response to this event.
083: */
084: public Rectangle getUpdateRect() {
085: return updateRect;
086: }
087:
088: /**
089: * Sets the rectangle representing the area which needs to be
090: * repainted in response to this event.
091: * @param updateRect the rectangle area which needs to be repainted
092: */
093: public void setUpdateRect(Rectangle updateRect) {
094: this .updateRect = updateRect;
095: }
096:
097: public String paramString() {
098: String typeStr;
099: switch (id) {
100: case PAINT:
101: typeStr = "PAINT";
102: break;
103:
104: case UPDATE:
105: typeStr = "UPDATE";
106: break;
107:
108: default:
109: typeStr = "unknown type";
110: }
111: return typeStr + ",updateRect="
112: + (updateRect != null ? updateRect.toString() : "null");
113: }
114: }
|