1. /*
  2. * @(#)TextEvent.java 1.14 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.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.14 01/23/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.
  53. *
  54. * @param source the (<code>TextComponent</code>) object that
  55. * originated the event
  56. * @param id an integer that identifies the event type
  57. */
  58. public TextEvent(Object source, int id) {
  59. super(source, id);
  60. }
  61. /**
  62. * Returns a parameter string identifying this text event.
  63. * This method is useful for event-logging and for debugging.
  64. *
  65. * @return a string identifying the event and its attributes
  66. */
  67. public String paramString() {
  68. String typeStr;
  69. switch(id) {
  70. case TEXT_VALUE_CHANGED:
  71. typeStr = "TEXT_VALUE_CHANGED";
  72. break;
  73. default:
  74. typeStr = "unknown type";
  75. }
  76. return typeStr;
  77. }
  78. }