aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/AWTEvent.java
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@waitaki.otago.ac.nz>2002-08-09 04:26:17 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2002-08-09 05:26:17 +0100
commit7bde45b2eb84502b62e77e46d947e46dcbd333d6 (patch)
treecdf9958b411887bead2263ea8ef0bdfc8eae6319 /libjava/java/awt/AWTEvent.java
parent097684ce62b505168739fc98e952f92a8719a1fa (diff)
downloadgcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.zip
gcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.tar.gz
gcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.tar.bz2
AWT/Swing merge from GNU Classpath.
From-SVN: r56147
Diffstat (limited to 'libjava/java/awt/AWTEvent.java')
-rw-r--r--libjava/java/awt/AWTEvent.java227
1 files changed, 144 insertions, 83 deletions
diff --git a/libjava/java/awt/AWTEvent.java b/libjava/java/awt/AWTEvent.java
index 17975fc..41cdad5 100644
--- a/libjava/java/awt/AWTEvent.java
+++ b/libjava/java/awt/AWTEvent.java
@@ -1,4 +1,5 @@
-/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
+/* AWTEvent.java -- the root event in AWT
+ Copyright (C) 1999, 2000, 2002 Free Software Foundation
This file is part of GNU Classpath.
@@ -37,123 +38,169 @@ exception statement from your version. */
package java.awt;
-/* Written using on-line Java 2 Platform Standard Edition v1.3 API
- * 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.
- */
+import java.util.EventObject;
/**
* AWTEvent is the root event class for all AWT events in the JDK 1.1 event
- * model. It supersedes the Event class from JDK 1.0.
+ * model. It supersedes the Event class from JDK 1.0. Subclasses outside of
+ * the java.awt package should have IDs greater than RESERVED_ID_MAX.
+ *
+ * <p>Event masks defined here are used by components in
+ * <code>enableEvents</code> to select event types not selected by registered
+ * listeners. Event masks are appropriately set when registering on
+ * components.
+ *
* @author Warren Levy <warrenl@cygnus.com>
- * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Aaron M. Renn <arenn@urbanophile.com>
+ * @since 1.1
+ * @status updated to 1.4
*/
-public abstract class AWTEvent extends java.util.EventObject
+public abstract class AWTEvent extends EventObject
{
/**
- * @serial Indicates whether or not this event has been consumed.
+ * Compatible with JDK 1.1+.
*/
- protected boolean consumed;
+ private static final long serialVersionUID = -1825314779160409405L;
/**
- * @serial The identifier number of this event.
+ * The ID of the event.
+ *
+ * @see #getID()
+ * @see #AWTEvent(Object, int)
+ * @serial the identifier number of this event
*/
protected int id;
/**
- * Mask for selecting component events.
- */
- public static final long COMPONENT_EVENT_MASK = 0x001;
+ * Indicates if the event has been consumed. False mean it is passed to
+ * the peer, true means it has already been processed. Semantic events
+ * generated by low-level events always have the value true.
+ *
+ * @see #consume()
+ * @see #isConsumed()
+ * @serial whether the event has been consumed
+ */
+ protected boolean consumed;
/**
- * Mask for selecting container events.
- */
- public static final long CONTAINER_EVENT_MASK = 0x002;
+ * Who knows? It's in the serial version.
+ *
+ * @serial No idea what this is for.
+ */
+ byte[] bdata;
+
+ /** Mask for selecting component events. */
+ public static final long COMPONENT_EVENT_MASK = 0x00001;
+
+ /** Mask for selecting container events. */
+ public static final long CONTAINER_EVENT_MASK = 0x00002;
+
+ /** Mask for selecting component focus events. */
+ public static final long FOCUS_EVENT_MASK = 0x00004;
+
+ /** Mask for selecting keyboard events. */
+ public static final long KEY_EVENT_MASK = 0x00008;
+
+ /** Mask for mouse button events. */
+ public static final long MOUSE_EVENT_MASK = 0x00010;
+
+ /** Mask for mouse motion events. */
+ public static final long MOUSE_MOTION_EVENT_MASK = 0x00020;
+
+ /** Mask for window events. */
+ public static final long WINDOW_EVENT_MASK = 0x00040;
+
+ /** Mask for action events. */
+ public static final long ACTION_EVENT_MASK = 0x00080;
+
+ /** Mask for adjustment events. */
+ public static final long ADJUSTMENT_EVENT_MASK = 0x00100;
+
+ /** Mask for item events. */
+ public static final long ITEM_EVENT_MASK = 0x00200;
+
+ /** Mask for text events. */
+ public static final long TEXT_EVENT_MASK = 0x00400;
/**
- * Mask for selecting component focus events.
- */
- public static final long FOCUS_EVENT_MASK = 0x004;
+ * Mask for input method events.
+ * @since 1.3
+ */
+ public static final long INPUT_METHOD_EVENT_MASK = 0x00800;
/**
- * Mask for selecting keyboard events.
- */
- public static final long KEY_EVENT_MASK = 0x008;
+ * Mask if input methods are enabled. Package visible only.
+ */
+ static final long INPUT_ENABLED_EVENT_MASK = 0x01000;
/**
- * Mask for mouse button events.
- */
- public static final long MOUSE_EVENT_MASK = 0x010;
+ * Mask for paint events.
+ * @since 1.3
+ */
+ public static final long PAINT_EVENT_MASK = 0x02000;
/**
- * Mask for mouse motion events.
- */
- public static final long MOUSE_MOTION_EVENT_MASK = 0x020;
+ * Mask for invocation events.
+ * @since 1.3
+ */
+ public static final long INVOCATION_EVENT_MASK = 0x04000;
/**
- * Mask for window events.
- */
- public static final long WINDOW_EVENT_MASK = 0x040;
+ * Mask for hierarchy events.
+ * @since 1.3
+ */
+ public static final long HIERARCHY_EVENT_MASK = 0x08000;
/**
- * Mask for action events.
- */
- public static final long ACTION_EVENT_MASK = 0x080;
+ * Mask for hierarchy bounds events.
+ * @since 1.3
+ */
+ public static final long HIERARCHY_BOUNDS_EVENT_MASK = 0x10000;
/**
- * Mask for adjustment events.
- */
- public static final long ADJUSTMENT_EVENT_MASK = 0x100;
+ * Mask for mouse wheel events.
+ * @since 1.4
+ */
+ public static final long MOUSE_WHEEL_EVENT_MASK = 0x20000;
/**
- * Mask for item events.
- */
- public static final long ITEM_EVENT_MASK = 0x200;
+ * Mask for window state events.
+ * @since 1.4
+ */
+ public static final long WINDOW_STATE_EVENT_MASK = 0x40000;
/**
- * Mask for text events.
- */
- public static final long TEXT_EVENT_MASK = 0x400;
+ * Mask for window focus events.
+ * @since 1.4
+ */
+ public static final long WINDOW_FOCUS_EVENT_MASK = 0x80000;
/**
* This is the highest number for event ids that are reserved for use by
- * the AWT system itself.
+ * the AWT system itself. Subclasses outside of java.awt should use higher
+ * ids.
*/
public static final int RESERVED_ID_MAX = 1999;
- public static final long INPUT_METHOD_EVENT_MASK = 1 << 11;
-
- /* Additional event selection masks from JDK 1.3 javadocs */
- public static final long PAINT_EVENT_MASK = 1 << 13,
- INVOCATION_EVENT_MASK = 1 << 14,
- HIERARCHY_EVENT_MASK = 1 << 15,
- HIERARCHY_BOUNDS_EVENT_MASK = 1 << 16;
-
+
/**
- * Initializes a new instance of <code>AWTEvent</code> from the
- * 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
+ * Initializes a new AWTEvent from the old Java 1.0 event object.
*
+ * @param event the old-style event
+ * @throws NullPointerException if event is null
*/
public AWTEvent(Event event)
{
- // FIXME??
- super(event.target);
- this.id = event.id;
+ this(event.target, event.id);
+ consumed = event.consumed;
}
/**
- * Initializes a new instance of <code>AWTEvent</code> with the specified
- * source and id.
+ * Create an event on the specified source object and id.
*
- * @param source The object that caused the event.
- * @param id The event id.
+ * @param source the object that caused the event
+ * @param id the event id
+ * @throws IllegalArgumentException if source is null
*/
public AWTEvent(Object source, int id)
{
@@ -162,9 +209,21 @@ public abstract class AWTEvent extends java.util.EventObject
}
/**
- * Returns the id number of this event.
+ * Retarget the event, such as converting a heavyweight component to a
+ * lightweight child of the original. This is not for general use, but
+ * is for event targeting systems like KeyboardFocusManager.
*
- * @return The id number of this event.
+ * @param source the new source
+ */
+ public void setSource(Object source)
+ {
+ this.source = source;
+ }
+
+ /**
+ * Returns the event type id.
+ *
+ * @return the id number of this event
*/
public int getID()
{
@@ -172,23 +231,26 @@ public abstract class AWTEvent extends java.util.EventObject
}
/**
- * Returns a string representation of this event.
+ * Returns a string representation of this event. This is in the format
+ * <code>getClass().getName() + '[' + paramString() + "] on "
+ * + source</code>.
*
- * @return A string representation of this event.
+ * @return a string representation of this event
*/
- public String paramString ()
+ public String toString()
{
- return "";
+ return getClass().getName() + "[" + paramString() + "] on " + source;
}
/**
- * Returns a string representation of this event.
+ * Returns a string representation of the state of this event. It may be
+ * empty, but must not be null; it is implementation defined.
*
- * @return A string representation of this event.
+ * @return a string representation of this event
*/
- public String toString ()
+ public String paramString()
{
- return getClass().getName() + "[" + paramString() + "] on " + source;
+ return "";
}
/**
@@ -201,14 +263,13 @@ public abstract class AWTEvent extends java.util.EventObject
}
/**
- * Tests whether not not this event has been consumed. A consumed event
+ * Tests whether not not this event has been consumed. A consumed event
* is not processed in the default manner.
*
- * @return <code>true</code> if this event has been consumed,
- * <code>false</code> otherwise.
+ * @return true if this event has been consumed
*/
protected boolean isConsumed()
{
return consumed;
}
-}
+} // class AWTEvent