1. /*
  2. * @(#)TextEvent.java 1.9 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.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. * @see java.awt.TextComponent
  23. * @see TextListener
  24. * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/textlistener.html">Tutorial: Writing a Text Listener</a>
  25. * @see <a href="http://www.awl.com/cp/javaseries/jcl1_2.html">Reference: The Java Class Libraries (update file)</a>
  26. *
  27. * @version 1.9 11/29/01
  28. * @author Georges Saab
  29. */
  30. public class TextEvent extends AWTEvent {
  31. /**
  32. * The first number in the range of ids used for text events.
  33. */
  34. public static final int TEXT_FIRST = 900;
  35. /**
  36. * The last number in the range of ids used for text events.
  37. */
  38. public static final int TEXT_LAST = 900;
  39. /**
  40. * This event id indicates that object's text changed.
  41. */
  42. public static final int TEXT_VALUE_CHANGED = TEXT_FIRST;
  43. /*
  44. * JDK 1.1 serialVersionUID
  45. */
  46. private static final long serialVersionUID = 6269902291250941179L;
  47. /**
  48. * Constructs a TextEvent object.
  49. *
  50. * @param source the (TextComponent) object that originated the event
  51. * @param id an integer that identifies the event type
  52. */
  53. public TextEvent(Object source, int id) {
  54. super(source, id);
  55. }
  56. /**
  57. * Returns a parameter string identifying this text event.
  58. * This method is useful for event-logging and for debugging.
  59. *
  60. * @return a string identifying the event and its attributes
  61. */
  62. public String paramString() {
  63. String typeStr;
  64. switch(id) {
  65. case TEXT_VALUE_CHANGED:
  66. typeStr = "TEXT_VALUE_CHANGED";
  67. break;
  68. default:
  69. typeStr = "unknown type";
  70. }
  71. return typeStr;
  72. }
  73. }