1. /*
  2. * @(#)PaintEvent.java 1.12 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.event;
  8. import java.awt.Component;
  9. import java.awt.Event;
  10. import java.awt.Rectangle;
  11. /**
  12. * The component-level paint event.
  13. * This event is a special type which is used to ensure that
  14. * paint/update method calls are serialized along with the other
  15. * events delivered from the event queue. This event is not
  16. * designed to be used with the Event Listener model; programs
  17. * should continue to override paint/update methods in order
  18. * render themselves properly.
  19. *
  20. * @version 1.12 11/29/01
  21. * @author Amy Fowler
  22. */
  23. public class PaintEvent extends ComponentEvent {
  24. /**
  25. * Marks the first integer id for the range of paint event ids.
  26. */
  27. public static final int PAINT_FIRST = 800;
  28. /**
  29. * Marks the last integer id for the range of paint event ids.
  30. */
  31. public static final int PAINT_LAST = 801;
  32. /**
  33. * The paint event type.
  34. */
  35. public static final int PAINT = PAINT_FIRST;
  36. /**
  37. * The update event type.
  38. */
  39. public static final int UPDATE = PAINT_FIRST + 1; //801
  40. /**
  41. * This is the rectangle that represents the area on the source
  42. * component that requires a repaint.
  43. * This rectangle should be non null.
  44. *
  45. * @serial
  46. * @see java.awt.Rectangle
  47. * @see setUpdateRect()
  48. * @see getUpdateRect()
  49. */
  50. Rectangle updateRect;
  51. /*
  52. * JDK 1.1 serialVersionUID
  53. */
  54. private static final long serialVersionUID = 1267492026433337593L;
  55. /**
  56. * Constructs a PaintEvent object with the specified source component
  57. * and type.
  58. * @param source the object where the event originated
  59. * @param id the event type
  60. * @param updateRect the rectangle area which needs to be repainted
  61. */
  62. public PaintEvent(Component source, int id, Rectangle updateRect) {
  63. super(source, id);
  64. this.updateRect = updateRect;
  65. }
  66. /**
  67. * Returns the rectangle representing the area which needs to be
  68. * repainted in response to this event.
  69. */
  70. public Rectangle getUpdateRect() {
  71. return updateRect;
  72. }
  73. /**
  74. * Sets the rectangle representing the area which needs to be
  75. * repainted in response to this event.
  76. * @param updateRect the rectangle area which needs to be repainted
  77. */
  78. public void setUpdateRect(Rectangle updateRect) {
  79. this.updateRect = updateRect;
  80. }
  81. public String paramString() {
  82. String typeStr;
  83. switch(id) {
  84. case PAINT:
  85. typeStr = "PAINT";
  86. break;
  87. case UPDATE:
  88. typeStr = "UPDATE";
  89. break;
  90. default:
  91. typeStr = "unknown type";
  92. }
  93. return typeStr + ",updateRect="+(updateRect != null ? updateRect.toString() : "null");
  94. }
  95. }