/[classpath]/classpath/java/awt/event/FocusEvent.java
ViewVC logotype

Diff of /classpath/java/awt/event/FocusEvent.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by mark, Tue Jan 22 22:26:59 2002 UTC revision 1.5 by ericb, Sat Mar 30 12:02:30 2002 UTC
# Line 1  Line 1 
1  /* FocusEvent.java -- Generated for a focus change.  /* FocusEvent.java -- generated for a focus change
2     Copyright (C) 1999 Free Software Foundation, Inc.     Copyright (C) 1999, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 41  package java.awt.event; Line 41  package java.awt.event;
41  import java.awt.Component;  import java.awt.Component;
42    
43  /**  /**
44    * This class represents an event generated when a focus change occurs   * This class represents an event generated when a focus change occurs for a
45    * for a component.   * component. There are both temporary changes, such as when focus is stolen
46    *   * during a sroll then returned, and permanent changes, such as when the user
47    * @author Aaron M. Renn (arenn@urbanophile.com)   * TABs through focusable components.
48    */   *
49  public class FocusEvent extends ComponentEvent implements java.io.Serializable   * @author Aaron M. Renn <arenn@urbanophile.com>
50  {   * @see FocusAdapter
51     * @see FocusListener
52  /*   * @since 1.1
53   * Static Variables   * @status updated to 1.4
  */  
   
 /**  
   * This is the first id in the range of ids used by this class.  
   */  
 public static final int FOCUS_FIRST = 1004;  
   
 /**  
   * This is the last id in the range of ids used by this class.  
   */  
 public static final int FOCUS_LAST = 1005;  
   
 /**  
   * This is the event id for a focus gained event.  
   */  
 public static final int FOCUS_GAINED = 1004;  
   
 /**  
   * This is the event id for a focus lost event.  
   */  
 public static final int FOCUS_LOST = 1005;  
   
 /*************************************************************************/  
   
 /*  
  * Instance Variables  
  */  
   
 /**  
   * @serial Indicates whether or not the focus change is temporary  
   */  
 private boolean temporary;  
   
 /*************************************************************************/  
   
 /*  
  * Constructors  
54   */   */
55    public class FocusEvent extends ComponentEvent
 /**  
   * Initializes a new instance of <code>FocusEvent</code> with the  
   * specified source and id.  
   *  
   * @param source The component that is gaining or losing focus.  
   * @param id The event id.  
   */  
 public  
 FocusEvent(Component source, int id)  
 {  
   super(source, id);  
 }  
   
 /*************************************************************************/  
   
 /**  
   * Initializes a new instance of <code>FocusEvent</code> with the  
   * specified source and id.  A third parameter indicates whether or  
   * not the focus change is temporary.  
   *  
   * @param source The component that is gaining or losing focus.  
   * @param id The event id.  
   * @param temporary <code>true</code> if the focus change is temporary,  
   * <code>false</code> otherwise.  
   */  
 public  
 FocusEvent(Component source, int id, boolean temporary)  
 {  
   this(source, id);  
   this.temporary = temporary;  
 }  
   
 /*************************************************************************/  
   
 /*  
  * Instance Methods  
  */  
   
 /**  
   * This method tests whether or not the focus change is temporary or  
   * permanent.  
   *  
   * @return <code>true</code> if the focus change is temporary,  
   * <code>false</code> otherwise.  
   */  
 public boolean  
 isTemporary()  
56  {  {
57    return(temporary);    /**
58  }     * Compatible with JDK 1.1+.
59       */
60  /*************************************************************************/    private static final long serialVersionUID = 523753786457416396L;
61    
62  /**    /** This is the first id in the range of ids used by this class. */
63    * Returns a string identifying this event.    public static final int FOCUS_FIRST = 1004;
64    *  
65    * @return A string identifying this event.    /** This is the last id in the range of ids used by this class. */
66    */    public static final int FOCUS_LAST = 1005;
67  public String  
68  paramString()    /** This is the event id for a focus gained event. */
69  {    public static final int FOCUS_GAINED = 1004;
70    return(getClass().getName() + " source=" + getSource() + " id=" + getID() +  
71           " temporary=" + isTemporary());    /** This is the event id for a focus lost event. */
72  }    public static final int FOCUS_LOST = 1005;
73    
74      /**
75       * Indicates whether or not the focus change is temporary.
76       *
77       * @see #isTemporary()
78       * @serial true if the focus change is temporary
79       */
80      private final boolean temporary;
81    
82      /**
83       * The other component which is giving up or stealing focus from this
84       * component, if known.
85       *
86       * @see #getOppositeComponent()
87       * @serial the component with the opposite focus event, or null
88       * @since 1.4
89       */
90      private final Component opposite;
91    
92      /**
93       * Initializes a new instance of <code>FocusEvent</code> with the
94       * specified source, id, temporary status, and opposite counterpart. Note
95       * that an invalid id leads to unspecified results.
96       *
97       * @param source the component that is gaining or losing focus
98       * @param id the event id
99       * @param temporary true if the focus change is temporary
100       * @param opposite the component receiving the opposite focus event, or null
101       * @throws IllegalArgumentException if source is null
102       */
103      public FocusEvent(Component source, int id, boolean temporary,
104                        Component opposite)
105      {
106        super(source, id);
107        this.temporary = temporary;
108        this.opposite = opposite;
109      }
110    
111      /**
112       * Initializes a new instance of <code>FocusEvent</code> with the
113       * specified source, id, and temporary status. Note that an invalid id
114       * leads to unspecified results.
115       *
116       * @param source the component that is gaining or losing focus
117       * @param id the event id
118       * @param temporary true if the focus change is temporary
119       * @throws IllegalArgumentException if source is null
120       */
121      public FocusEvent(Component source, int id, boolean temporary)
122      {
123        this(source, id, temporary, null);
124      }
125    
126      /**
127       * Initializes a new instance of <code>FocusEvent</code> with the
128       * specified source and id. Note that an invalid id leads to unspecified
129       * results.
130       *
131       * @param source the component that is gaining or losing focus
132       * @param id the event id
133       * @throws IllegalArgumentException if source is null
134       */
135      public FocusEvent(Component source, int id)
136      {
137        this(source, id, false, null);
138      }
139    
140      /**
141       * This method tests whether or not the focus change is temporary or
142       * permanent.
143       *
144       * @return true if the focus change is temporary
145       */
146      public boolean isTemporary()
147      {
148        return temporary;
149      }
150    
151      /**
152       * Returns the component which received the opposite focus event. If this
153       * component gained focus, the opposite lost focus; likewise if this
154       * component is giving up focus, the opposite is gaining it. If this
155       * information is unknown, perhaps because the opposite is a native
156       * application, this returns null.
157       *
158       * @return the component with the focus opposite, or null
159       * @since 1.4
160       */
161      public Component getOppositeComponent()
162      {
163        return opposite;
164      }
165    
166      /**
167       * Returns a string identifying this event. This is formatted as:
168       * <code>(getID() == FOCUS_GAINED ? "FOCUS_GAINED" : "FOCUS_LOST")
169       * + (isTemporary() ? ",temporary," : ",permanent,") + "opposite="
170       * + getOppositeComponent()</code>.
171       *
172       * @return a string identifying this event
173       */
174      public String paramString()
175      {
176        return (id == FOCUS_GAINED ? "FOCUS_GAINED"
177                : id == FOCUS_LOST ? "FOCUS_LOST" : "unknown type")
178          + (temporary ? ",temporary,opposite=" : ",permanent,opposite=")
179          + opposite;
180      }
181  } // class FocusEvent  } // class FocusEvent
   

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26