Save This Page
Home » openjdk-7 » java » awt » event » [javadoc | source]
    1   /*
    2    * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package java.awt.event;
   27   
   28   import java.awt.AWTEvent;
   29   
   30   /**
   31    * A semantic event which indicates that an object's text changed.
   32    * This high-level event is generated by an object (such as a TextComponent)
   33    * when its text changes. The event is passed to
   34    * every <code>TextListener</code> object which registered to receive such
   35    * events using the component's <code>addTextListener</code> method.
   36    * <P>
   37    * The object that implements the <code>TextListener</code> interface gets
   38    * this <code>TextEvent</code> when the event occurs. The listener is
   39    * spared the details of processing individual mouse movements and key strokes
   40    * Instead, it can process a "meaningful" (semantic) event like "text changed".
   41    * <p>
   42    * An unspecified behavior will be caused if the {@code id} parameter
   43    * of any particular {@code TextEvent} instance is not
   44    * in the range from {@code TEXT_FIRST} to {@code TEXT_LAST}.
   45    *
   46    * @author Georges Saab
   47    *
   48    * @see java.awt.TextComponent
   49    * @see TextListener
   50    *
   51    * @since 1.1
   52    */
   53   
   54   public class TextEvent extends AWTEvent {
   55   
   56       /**
   57        * The first number in the range of ids used for text events.
   58        */
   59       public static final int TEXT_FIRST  = 900;
   60   
   61       /**
   62        * The last number in the range of ids used for text events.
   63        */
   64       public static final int TEXT_LAST   = 900;
   65   
   66       /**
   67        * This event id indicates that object's text changed.
   68        */
   69       public static final int TEXT_VALUE_CHANGED  = TEXT_FIRST;
   70   
   71       /*
   72        * JDK 1.1 serialVersionUID
   73        */
   74       private static final long serialVersionUID = 6269902291250941179L;
   75   
   76       /**
   77        * Constructs a <code>TextEvent</code> object.
   78        * <p> This method throws an
   79        * <code>IllegalArgumentException</code> if <code>source</code>
   80        * is <code>null</code>.
   81        *
   82        * @param source The (<code>TextComponent</code>) object that
   83        *               originated the event
   84        * @param id     An integer that identifies the event type.
   85        *                     For information on allowable values, see
   86        *                     the class description for {@link TextEvent}
   87        * @throws IllegalArgumentException if <code>source</code> is null
   88        * @see #getSource()
   89        * @see #getID()
   90        */
   91       public TextEvent(Object source, int id) {
   92           super(source, id);
   93       }
   94   
   95   
   96       /**
   97        * Returns a parameter string identifying this text event.
   98        * This method is useful for event-logging and for debugging.
   99        *
  100        * @return a string identifying the event and its attributes
  101        */
  102       public String paramString() {
  103           String typeStr;
  104           switch(id) {
  105             case TEXT_VALUE_CHANGED:
  106                 typeStr = "TEXT_VALUE_CHANGED";
  107                 break;
  108             default:
  109                 typeStr = "unknown type";
  110           }
  111           return typeStr;
  112       }
  113   }

Save This Page
Home » openjdk-7 » java » awt » event » [javadoc | source]