1. /*
  2. * @(#)TextEvent.java 1.16 03/12/19
  3. *
  4. * Copyright 2004 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.AWTEvent;
  9. import java.awt.Event;
  10. /**
  11. * A semantic event which indicates that an object's text changed.
  12. * This high-level event is generated by an object (such as a TextComponent)
  13. * when its text changes. The event is passed to
  14. * every <code>TextListener</code> object which registered to receive such
  15. * events using the component's <code>addTextListener</code> method.
  16. * <P>
  17. * The object that implements the <code>TextListener</code> interface gets
  18. * this <code>TextEvent</code> when the event occurs. The listener is
  19. * spared the details of processing individual mouse movements and key strokes
  20. * Instead, it can process a "meaningful" (semantic) event like "text changed".
  21. *
  22. * @author Georges Saab
  23. * @version 1.16 12/19/03
  24. *
  25. * @see java.awt.TextComponent
  26. * @see TextListener
  27. * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/textlistener.html">Tutorial: Writing a Text Listener</a>
  28. * @see <a href="http://www.awl.com/cp/javaseries/jcl1_2.html">Reference: The Java Class Libraries (update file)</a>
  29. *
  30. * @since 1.1
  31. */
  32. public class TextEvent extends AWTEvent {
  33. /**
  34. * The first number in the range of ids used for text events.
  35. */
  36. public static final int TEXT_FIRST = 900;
  37. /**
  38. * The last number in the range of ids used for text events.
  39. */
  40. public static final int TEXT_LAST = 900;
  41. /**
  42. * This event id indicates that object's text changed.
  43. */
  44. public static final int TEXT_VALUE_CHANGED = TEXT_FIRST;
  45. /*
  46. * JDK 1.1 serialVersionUID
  47. */
  48. private static final long serialVersionUID = 6269902291250941179L;
  49. /**
  50. * Constructs a <code>TextEvent</code> object.
  51. * <p>Note that passing in an invalid <code>id</code> results in
  52. * unspecified behavior. This method throws an
  53. * <code>IllegalArgumentException</code> if <code>source</code>
  54. * is <code>null</code>.
  55. *
  56. * @param source the (<code>TextComponent</code>) object that
  57. * originated the event
  58. * @param id an integer that identifies the event type
  59. * @throws IllegalArgumentException if <code>source</code> is null
  60. */
  61. public TextEvent(Object source, int id) {
  62. super(source, id);
  63. }
  64. /**
  65. * Returns a parameter string identifying this text event.
  66. * This method is useful for event-logging and for debugging.
  67. *
  68. * @return a string identifying the event and its attributes
  69. */
  70. public String paramString() {
  71. String typeStr;
  72. switch(id) {
  73. case TEXT_VALUE_CHANGED:
  74. typeStr = "TEXT_VALUE_CHANGED";
  75. break;
  76. default:
  77. typeStr = "unknown type";
  78. }
  79. return typeStr;
  80. }
  81. }