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