/[classpath]/classpath/java/awt/AWTEvent.java
ViewVC logotype

Diff of /classpath/java/awt/AWTEvent.java

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

revision 1.8 by brawer, Tue Mar 19 16:17:40 2002 UTC revision 1.9 by ericb, Wed Mar 20 04:56:08 2002 UTC
# Line 1  Line 1 
1  /* Copyright (C) 1999, 2000, 2002  Free Software Foundation  /* AWTEvent.java -- the root event in AWT
2       Copyright (C) 1999, 2000, 2002 Free Software Foundation
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 37  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.awt;  package java.awt;
40    
41  /* Written using on-line Java 2 Platform Standard Edition v1.3 API  import java.util.EventObject;
  * Specification, as well as "The Java Class Libraries", 2nd edition  
  * (Addison-Wesley, 1998).  
  * Status:  Believed complete and correct, except for the java.awt.Event  
  * compatibility constructor.  
  */  
42    
43  /**  /**
44   * AWTEvent is the root event class for all AWT events in the JDK 1.1 event   * AWTEvent is the root event class for all AWT events in the JDK 1.1 event
45   * model. It supersedes the Event class from JDK 1.0.   * model. It supersedes the Event class from JDK 1.0. Subclasses outside of
46     * the java.awt package should have IDs greater than RESERVED_ID_MAX.
47     *
48     * <p>Event masks defined here are used by components in
49     * <code>enableEvents</code> to select event types not selected by registered
50     * listeners. Event masks are appropriately set when registering on
51     * components.
52     *
53   * @author Warren Levy  <warrenl@cygnus.com>   * @author Warren Levy  <warrenl@cygnus.com>
54   * @author Aaron M. Renn (arenn@urbanophile.com)   * @author Aaron M. Renn <arenn@urbanophile.com>
55     * @since 1.1
56     * @status updated to 1.4
57   */   */
58  public abstract class AWTEvent extends java.util.EventObject  public abstract class AWTEvent extends EventObject
59  {  {
60    /**    /**
61     * @serial Indicates whether or not this event has been consumed.     * Compatible with JDK 1.1+.
62     */     */
63    protected boolean consumed;    private static final long serialVersionUID = -1825314779160409405L;
64    
65    /**    /**
66     * @serial The identifier number of this event.     * The ID of the event.
67       *
68       * @see #getID()
69       * @see #AWTEvent(Object, int)
70       * @serial the identifier number of this event
71     */     */
72    protected int id;    protected int id;
73    
74    /**    /**
75    * Mask for selecting component events.     * Indicates if the event has been consumed. False mean it is passed to
76    */     * the peer, true means it has already been processed. Semantic events
77    public static final long COMPONENT_EVENT_MASK = 0x001;     * generated by low-level events always have the value true.
78       *
79       * @see #consume()
80       * @see #isConsumed()
81       * @serial whether the event has been consumed
82       */
83      protected boolean consumed;
84    
85    /**    /**
86    * Mask for selecting container events.     * Who knows? It's in the serial version.
87    */     *
88    public static final long CONTAINER_EVENT_MASK = 0x002;     * @serial No idea what this is for.
89       */
90      byte[] bdata;
91    
92    /**    /** Mask for selecting component events. */
93    * Mask for selecting component focus events.    public static final long COMPONENT_EVENT_MASK = 0x00001;
   */  
   public static final long FOCUS_EVENT_MASK = 0x004;  
94    
95    /**    /** Mask for selecting container events. */
96    * Mask for selecting keyboard events.    public static final long CONTAINER_EVENT_MASK = 0x00002;
   */  
   public static final long KEY_EVENT_MASK = 0x008;  
97    
98    /**    /** Mask for selecting component focus events. */
99    * Mask for mouse button events.    public static final long FOCUS_EVENT_MASK = 0x00004;
   */  
   public static final long MOUSE_EVENT_MASK = 0x010;  
100    
101    /**    /** Mask for selecting keyboard events. */
102    * Mask for mouse motion events.    public static final long KEY_EVENT_MASK = 0x00008;
   */  
   public static final long MOUSE_MOTION_EVENT_MASK = 0x020;  
103    
104    /**    /** Mask for mouse button events. */
105    * Mask for window events.    public static final long MOUSE_EVENT_MASK = 0x00010;
   */  
   public static final long WINDOW_EVENT_MASK = 0x040;  
106    
107    /**    /** Mask for mouse motion events. */
108    * Mask for action events.    public static final long MOUSE_MOTION_EVENT_MASK = 0x00020;
   */  
   public static final long ACTION_EVENT_MASK = 0x080;  
109    
110    /**    /** Mask for window events. */
111    * Mask for adjustment events.    public static final long WINDOW_EVENT_MASK = 0x00040;
   */  
   public static final long ADJUSTMENT_EVENT_MASK = 0x100;  
112    
113    /**    /** Mask for action events. */
114    * Mask for item events.    public static final long ACTION_EVENT_MASK = 0x00080;
115    */  
116    public static final long ITEM_EVENT_MASK = 0x200;    /** Mask for adjustment events. */
117      public static final long ADJUSTMENT_EVENT_MASK = 0x00100;
118    
119      /** Mask for item events. */
120      public static final long ITEM_EVENT_MASK = 0x00200;
121    
122      /** Mask for text events. */
123      public static final long TEXT_EVENT_MASK = 0x00400;
124    
125    /**    /**
126    * Mask for text events.     * Mask for input method events.
127    */     * @since 1.3
128    public static final long TEXT_EVENT_MASK = 0x400;     */
129      public static final long INPUT_METHOD_EVENT_MASK = 0x00800;
130    
131    /**    /**
132    * This is the highest number for event ids that are reserved for use by     * Mask for paint events.
133    * the AWT system itself.     * @since 1.3
134    */     */
135    public static final int RESERVED_ID_MAX = 1999;    public static final long PAINT_EVENT_MASK = 0x02000;
136    
137    public static final long INPUT_METHOD_EVENT_MASK = 1 << 11;    /**
138       * Mask for invocation events.
139       * @since 1.3
140       */
141      public static final long INVOCATION_EVENT_MASK = 0x04000;
142    
143    /* Additional event selection masks from JDK 1.3 javadocs */    /**
144    public static final long PAINT_EVENT_MASK            = 1 << 13,     * Mask for hierarchy events.
145                             INVOCATION_EVENT_MASK       = 1 << 14,     * @since 1.3
146                             HIERARCHY_EVENT_MASK        = 1 << 15,     */
147                             HIERARCHY_BOUNDS_EVENT_MASK = 1 << 16;    public static final long HIERARCHY_EVENT_MASK = 0x08000;
148    
149      /**
150       * Mask for hierarchy bounds events.
151       * @since 1.3
152       */
153      public static final long HIERARCHY_BOUNDS_EVENT_MASK = 0x10000;
154    
155    /**    /**
156     * The mask for mouse wheel events.     * Mask for mouse wheel events.
157     * @since 1.4     * @since 1.4
158     */     */
159    public static final long MOUSE_WHEEL_EVENT_MASK = 1 << 17;    public static final long MOUSE_WHEEL_EVENT_MASK = 0x20000;
   
160    
161    /**    /**
162     * The mask for window state events.     * Mask for window state events.
163     * @since 1.4     * @since 1.4
164     */     */
165    public static final long WINDOW_STATE_EVENT_MASK = 1 << 18;    public static final long WINDOW_STATE_EVENT_MASK = 0x40000;
   
166    
167    /**    /**
168     * The mask for window focus events.     * Mask for window focus events.
169     * @since 1.4     * @since 1.4
170     */     */
171    public static final long WINDOW_FOCUS_EVENT_MASK = 1 << 19;    public static final long WINDOW_FOCUS_EVENT_MASK = 0x80000;
172    
173      /**
174      * This is the highest number for event ids that are reserved for use by
175      * the AWT system itself. Subclasses outside of java.awt should use higher
176      * ids.
177      */
178      public static final int RESERVED_ID_MAX = 1999;
179    
180    
181    /**    /**
182     * Initializes a new instance of <code>AWTEvent</code> from the     * Initializes a new AWTEvent from the old Java 1.0 event object.
    * specified Java 1.0 event object.  
    *  
    * @param event The Java 1.0 event to initialize from.  
    *  
    *  
    * Removed this method because we no longer support Java 1.0  
183     *     *
184       * @param event the old-style event
185       * @throws NullPointerException if event is null
186     */     */
187    public AWTEvent(Event event)    public AWTEvent(Event event)
188    {    {
189      // FIXME??      this(event.target, event.id);
190      super(event.target);      consumed = event.consumed;
     this.id = event.id;  
191    }    }
192    
193    /**    /**
194     * Initializes a new instance of <code>AWTEvent</code> with the specified     * Create an event on the specified source object and id.
    * source and id.  
195     *     *
196     * @param source The object that caused the event.     * @param source the object that caused the event
197     * @param id The event id.     * @param id the event id
198       * @throws IllegalArgumentException if source is null
199     */     */
200    public AWTEvent(Object source, int id)    public AWTEvent(Object source, int id)
201    {    {
# Line 184  public abstract class AWTEvent extends j Line 204  public abstract class AWTEvent extends j
204    }    }
205    
206    /**    /**
207     * Returns the id number of this event.     * Retarget the event, such as converting a heavyweight component to a
208       * lightweight child of the original. This is not for general use, but
209       * is for event targeting systems like KeyboardFocusManager.
210     *     *
211     * @return The id number of this event.     * @param source the new source
212       */
213      public void setSource(Object source)
214      {
215        this.source = source;
216      }
217    
218      /**
219       * Returns the event type id.
220       *
221       * @return the id number of this event
222     */     */
223    public int getID()    public int getID()
224    {    {
# Line 194  public abstract class AWTEvent extends j Line 226  public abstract class AWTEvent extends j
226    }    }
227    
228    /**    /**
229     * Returns a string representation of this event.     * Returns a string representation of this event. This is in the format
230       * <code>getClass().getName() + '[' + paramString() + "] on "
231       * + source</code>.
232     *     *
233     * @return A string representation of this event.     * @return a string representation of this event
234     */     */
235    public String paramString ()    public String toString()
236    {    {
237      return "";      return getClass().getName() + "[" + paramString() + "] on " + source;
238    }    }
239    
240    /**    /**
241     * Returns a string representation of this event.     * Returns a string representation of the state of this event. It may be
242       * empty, but must not be null; it is implementation defined.
243     *     *
244     * @return A string representation of this event.     * @return a string representation of this event
245     */     */
246    public String toString ()    public String paramString()
247    {    {
248      return getClass().getName() + "[" + paramString() + "] on " + source;      return "";
249    }    }
250    
251    /**    /**
# Line 223  public abstract class AWTEvent extends j Line 258  public abstract class AWTEvent extends j
258    }    }
259    
260    /**    /**
261     * Tests whether not not this event has been consumed.  A consumed event     * Tests whether not not this event has been consumed. A consumed event
262     * is not processed in the default manner.     * is not processed in the default manner.
263     *     *
264     * @return <code>true</code> if this event has been consumed,     * @return true if this event has been consumed
    * <code>false</code> otherwise.  
265     */     */
266    protected boolean isConsumed()    protected boolean isConsumed()
267    {    {
268      return consumed;      return consumed;
269    }    }
270  }  } // class AWTEvent

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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