1. /*
  2. * @(#)EventObject.java 1.11 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.util;
  8. /**
  9. * <p>
  10. * The Event class is the abstract root class from which all event state
  11. * objects shall be derived.
  12. * <p>
  13. * All Event's are constructed with a reference to the object, the "source",
  14. * that is logically deemed to be the object upon which the Event in question
  15. * initially occurred upon.
  16. */
  17. public class EventObject implements java.io.Serializable {
  18. /**
  19. * The object on which the Event initially occurred.
  20. */
  21. protected transient Object source;
  22. /**
  23. * Constructs a prototypical Event.
  24. *
  25. * @param source The object on which the Event initially occurred.
  26. */
  27. public EventObject(Object source) {
  28. if (source == null)
  29. throw new IllegalArgumentException("null source");
  30. this.source = source;
  31. }
  32. /**
  33. * The object on which the Event initially occurred.
  34. *
  35. * @return The object on which the Event initially occurred.
  36. */
  37. public Object getSource() {
  38. return source;
  39. }
  40. /**
  41. * Returns a String representation of this EventObject.
  42. *
  43. * @return A a String representation of this EventObject.
  44. */
  45. public String toString() {
  46. return getClass().getName() + "[source=" + source + "]";
  47. }
  48. }