KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > event > TextEvent


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
8 package java.awt.event;
9
10 import java.awt.AWTEvent JavaDoc;
11 import java.awt.Event JavaDoc;
12
13 /**
14  * A semantic event which indicates that an object's text changed.
15  * This high-level event is generated by an object (such as a TextComponent)
16  * when its text changes. The event is passed to
17  * every <code>TextListener</code> object which registered to receive such
18  * events using the component's <code>addTextListener</code> method.
19  * <P>
20  * The object that implements the <code>TextListener</code> interface gets
21  * this <code>TextEvent</code> when the event occurs. The listener is
22  * spared the details of processing individual mouse movements and key strokes
23  * Instead, it can process a "meaningful" (semantic) event like "text changed".
24  *
25  * @author Georges Saab
26  * @version 1.16 12/19/03
27  *
28  * @see java.awt.TextComponent
29  * @see TextListener
30  * @see <a HREF="http://java.sun.com/docs/books/tutorial/post1.0/ui/textlistener.html">Tutorial: Writing a Text Listener</a>
31  * @see <a HREF="http://www.awl.com/cp/javaseries/jcl1_2.html">Reference: The Java Class Libraries (update file)</a>
32  *
33  * @since 1.1
34  */

35
36 public class TextEvent extends AWTEvent JavaDoc {
37
38     /**
39      * The first number in the range of ids used for text events.
40      */

41     public static final int TEXT_FIRST = 900;
42
43     /**
44      * The last number in the range of ids used for text events.
45      */

46     public static final int TEXT_LAST = 900;
47
48     /**
49      * This event id indicates that object's text changed.
50      */

51     public static final int TEXT_VALUE_CHANGED = TEXT_FIRST;
52
53     /*
54      * JDK 1.1 serialVersionUID
55      */

56     private static final long serialVersionUID = 6269902291250941179L;
57
58     /**
59      * Constructs a <code>TextEvent</code> object.
60      * <p>Note that passing in an invalid <code>id</code> results in
61      * unspecified behavior. This method throws an
62      * <code>IllegalArgumentException</code> if <code>source</code>
63      * is <code>null</code>.
64      *
65      * @param source the (<code>TextComponent</code>) object that
66      * originated the event
67      * @param id an integer that identifies the event type
68      * @throws IllegalArgumentException if <code>source</code> is null
69      */

70     public TextEvent(Object JavaDoc source, int id) {
71         super(source, id);
72     }
73
74
75     /**
76      * Returns a parameter string identifying this text event.
77      * This method is useful for event-logging and for debugging.
78      *
79      * @return a string identifying the event and its attributes
80      */

81     public String JavaDoc paramString() {
82         String JavaDoc typeStr;
83         switch(id) {
84           case TEXT_VALUE_CHANGED:
85               typeStr = "TEXT_VALUE_CHANGED";
86               break;
87           default:
88               typeStr = "unknown type";
89         }
90         return typeStr;
91     }
92 }
93
94
95
Popular Tags