001 /*
002 * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.awt.event;
027
028 import java.awt.AWTEvent;
029
030 /**
031 * A semantic event which indicates that an object's text changed.
032 * This high-level event is generated by an object (such as a TextComponent)
033 * when its text changes. The event is passed to
034 * every <code>TextListener</code> object which registered to receive such
035 * events using the component's <code>addTextListener</code> method.
036 * <P>
037 * The object that implements the <code>TextListener</code> interface gets
038 * this <code>TextEvent</code> when the event occurs. The listener is
039 * spared the details of processing individual mouse movements and key strokes
040 * Instead, it can process a "meaningful" (semantic) event like "text changed".
041 *
042 * @author Georges Saab
043 * @version 1.26 06/05/07
044 *
045 * @see java.awt.TextComponent
046 * @see TextListener
047 * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/textlistener.html">Tutorial: Writing a Text Listener</a>
048 *
049 * @since 1.1
050 */
051
052 public class TextEvent extends AWTEvent {
053
054 /**
055 * The first number in the range of ids used for text events.
056 */
057 public static final int TEXT_FIRST = 900;
058
059 /**
060 * The last number in the range of ids used for text events.
061 */
062 public static final int TEXT_LAST = 900;
063
064 /**
065 * This event id indicates that object's text changed.
066 */
067 public static final int TEXT_VALUE_CHANGED = TEXT_FIRST;
068
069 /*
070 * JDK 1.1 serialVersionUID
071 */
072 private static final long serialVersionUID = 6269902291250941179L;
073
074 /**
075 * Constructs a <code>TextEvent</code> object.
076 * <p>Note that passing in an invalid <code>id</code> results in
077 * unspecified behavior. This method throws an
078 * <code>IllegalArgumentException</code> if <code>source</code>
079 * is <code>null</code>.
080 *
081 * @param source the (<code>TextComponent</code>) object that
082 * originated the event
083 * @param id an integer that identifies the event type
084 * @throws IllegalArgumentException if <code>source</code> is null
085 */
086 public TextEvent(Object source, int id) {
087 super (source, id);
088 }
089
090 /**
091 * Returns a parameter string identifying this text event.
092 * This method is useful for event-logging and for debugging.
093 *
094 * @return a string identifying the event and its attributes
095 */
096 public String paramString() {
097 String typeStr;
098 switch (id) {
099 case TEXT_VALUE_CHANGED:
100 typeStr = "TEXT_VALUE_CHANGED";
101 break;
102 default:
103 typeStr = "unknown type";
104 }
105 return typeStr;
106 }
107 }
|