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