FileDocCategorySizeDatePackage
AWTEvent.javaAPI DocAndroid 1.5 API24311Wed May 06 22:41:54 BST 2009java.awt

AWTEvent

public abstract class AWTEvent extends EventObject
The abstract class AWTEvent is the base class for all AWT events. This class and its subclasses supersede the original java.awt.Event class.
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
The Constant serialVersionUID.
public static final long
COMPONENT_EVENT_MASK
The Constant COMPONENT_EVENT_MASK indicates the event relates to a component.
public static final long
CONTAINER_EVENT_MASK
The Constant CONTAINER_EVENT_MASK indicates the event relates to a container.
public static final long
FOCUS_EVENT_MASK
The Constant FOCUS_EVENT_MASK indicates the event relates to the focus.
public static final long
KEY_EVENT_MASK
The Constant KEY_EVENT_MASK indicates the event relates to a key.
public static final long
MOUSE_EVENT_MASK
The Constant MOUSE_EVENT_MASK indicates the event relates to the mouse.
public static final long
MOUSE_MOTION_EVENT_MASK
The Constant MOUSE_MOTION_EVENT_MASK indicates the event relates to a mouse motion.
public static final long
WINDOW_EVENT_MASK
The Constant WINDOW_EVENT_MASK indicates the event relates to a window.
public static final long
ACTION_EVENT_MASK
The Constant ACTION_EVENT_MASK indicates the event relates to an action.
public static final long
ADJUSTMENT_EVENT_MASK
The Constant ADJUSTMENT_EVENT_MASK indicates the event relates to an adjustment.
public static final long
ITEM_EVENT_MASK
The Constant ITEM_EVENT_MASK indicates the event relates to an item.
public static final long
TEXT_EVENT_MASK
The Constant TEXT_EVENT_MASK indicates the event relates to text.
public static final long
INPUT_METHOD_EVENT_MASK
The Constant INPUT_METHOD_EVENT_MASK indicates the event relates to an input method.
public static final long
PAINT_EVENT_MASK
The Constant PAINT_EVENT_MASK indicates the event relates to a paint method.
public static final long
INVOCATION_EVENT_MASK
The Constant INVOCATION_EVENT_MASK indicates the event relates to a method invocation.
public static final long
HIERARCHY_EVENT_MASK
The Constant HIERARCHY_EVENT_MASK indicates the event relates to a hierarchy.
public static final long
HIERARCHY_BOUNDS_EVENT_MASK
The Constant HIERARCHY_BOUNDS_EVENT_MASK indicates the event relates to hierarchy bounds.
public static final long
MOUSE_WHEEL_EVENT_MASK
The Constant MOUSE_WHEEL_EVENT_MASK indicates the event relates to the mouse wheel.
public static final long
WINDOW_STATE_EVENT_MASK
The Constant WINDOW_STATE_EVENT_MASK indicates the event relates to a window state.
public static final long
WINDOW_FOCUS_EVENT_MASK
The Constant WINDOW_FOCUS_EVENT_MASK indicates the event relates to a window focus.
public static final int
RESERVED_ID_MAX
The Constant RESERVED_ID_MAX indicates the maximum value for reserved AWT event IDs.
private static final Hashtable
eventsMap
The Constant eventsMap.
private static EventConverter
converter
The converter.
protected int
id
The ID of the event.
protected boolean
consumed
The consumed indicates whether or not the event is sent back down to the peer once the source has processed it (false means it's sent to the peer, true means it's not).
boolean
dispatchedByKFM
The dispatched by kfm.
transient boolean
isPosted
The is posted.
Constructors Summary
public AWTEvent(Event event)
Instantiates a new AWT event from the specified Event object.

param
event the Event object.


     
        eventsMap.put(new Integer(KeyEvent.KEY_TYPED), new EventDescriptor(KEY_EVENT_MASK,
                KeyListener.class));
        eventsMap.put(new Integer(KeyEvent.KEY_PRESSED), new EventDescriptor(KEY_EVENT_MASK,
                KeyListener.class));
        eventsMap.put(new Integer(KeyEvent.KEY_RELEASED), new EventDescriptor(KEY_EVENT_MASK,
                KeyListener.class));
        eventsMap.put(new Integer(MouseEvent.MOUSE_CLICKED), new EventDescriptor(MOUSE_EVENT_MASK,
                MouseListener.class));
        eventsMap.put(new Integer(MouseEvent.MOUSE_PRESSED), new EventDescriptor(MOUSE_EVENT_MASK,
                MouseListener.class));
        eventsMap.put(new Integer(MouseEvent.MOUSE_RELEASED), new EventDescriptor(MOUSE_EVENT_MASK,
                MouseListener.class));
        eventsMap.put(new Integer(MouseEvent.MOUSE_MOVED), new EventDescriptor(
                MOUSE_MOTION_EVENT_MASK, MouseMotionListener.class));
        eventsMap.put(new Integer(MouseEvent.MOUSE_ENTERED), new EventDescriptor(MOUSE_EVENT_MASK,
                MouseListener.class));
        eventsMap.put(new Integer(MouseEvent.MOUSE_EXITED), new EventDescriptor(MOUSE_EVENT_MASK,
                MouseListener.class));
        eventsMap.put(new Integer(MouseEvent.MOUSE_DRAGGED), new EventDescriptor(
                MOUSE_MOTION_EVENT_MASK, MouseMotionListener.class));
        eventsMap.put(new Integer(MouseEvent.MOUSE_WHEEL), new EventDescriptor(
                MOUSE_WHEEL_EVENT_MASK, MouseWheelListener.class));
        eventsMap.put(new Integer(ComponentEvent.COMPONENT_MOVED), new EventDescriptor(
                COMPONENT_EVENT_MASK, ComponentListener.class));
        eventsMap.put(new Integer(ComponentEvent.COMPONENT_RESIZED), new EventDescriptor(
                COMPONENT_EVENT_MASK, ComponentListener.class));
        eventsMap.put(new Integer(ComponentEvent.COMPONENT_SHOWN), new EventDescriptor(
                COMPONENT_EVENT_MASK, ComponentListener.class));
        eventsMap.put(new Integer(ComponentEvent.COMPONENT_HIDDEN), new EventDescriptor(
                COMPONENT_EVENT_MASK, ComponentListener.class));
        eventsMap.put(new Integer(FocusEvent.FOCUS_GAINED), new EventDescriptor(FOCUS_EVENT_MASK,
                FocusListener.class));
        eventsMap.put(new Integer(FocusEvent.FOCUS_LOST), new EventDescriptor(FOCUS_EVENT_MASK,
                FocusListener.class));
        eventsMap.put(new Integer(PaintEvent.PAINT), new EventDescriptor(PAINT_EVENT_MASK, null));
        eventsMap.put(new Integer(PaintEvent.UPDATE), new EventDescriptor(PAINT_EVENT_MASK, null));
        eventsMap.put(new Integer(WindowEvent.WINDOW_OPENED), new EventDescriptor(
                WINDOW_EVENT_MASK, WindowListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_CLOSING), new EventDescriptor(
                WINDOW_EVENT_MASK, WindowListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_CLOSED), new EventDescriptor(
                WINDOW_EVENT_MASK, WindowListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_DEICONIFIED), new EventDescriptor(
                WINDOW_EVENT_MASK, WindowListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_ICONIFIED), new EventDescriptor(
                WINDOW_EVENT_MASK, WindowListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_STATE_CHANGED), new EventDescriptor(
                WINDOW_STATE_EVENT_MASK, WindowStateListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_LOST_FOCUS), new EventDescriptor(
                WINDOW_FOCUS_EVENT_MASK, WindowFocusListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_GAINED_FOCUS), new EventDescriptor(
                WINDOW_FOCUS_EVENT_MASK, WindowFocusListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_DEACTIVATED), new EventDescriptor(
                WINDOW_EVENT_MASK, WindowListener.class));
        eventsMap.put(new Integer(WindowEvent.WINDOW_ACTIVATED), new EventDescriptor(
                WINDOW_EVENT_MASK, WindowListener.class));
        eventsMap.put(new Integer(HierarchyEvent.HIERARCHY_CHANGED), new EventDescriptor(
                HIERARCHY_EVENT_MASK, HierarchyListener.class));
        eventsMap.put(new Integer(HierarchyEvent.ANCESTOR_MOVED), new EventDescriptor(
                HIERARCHY_BOUNDS_EVENT_MASK, HierarchyBoundsListener.class));
        eventsMap.put(new Integer(HierarchyEvent.ANCESTOR_RESIZED), new EventDescriptor(
                HIERARCHY_BOUNDS_EVENT_MASK, HierarchyBoundsListener.class));
        eventsMap.put(new Integer(ContainerEvent.COMPONENT_ADDED), new EventDescriptor(
                CONTAINER_EVENT_MASK, ContainerListener.class));
        eventsMap.put(new Integer(ContainerEvent.COMPONENT_REMOVED), new EventDescriptor(
                CONTAINER_EVENT_MASK, ContainerListener.class));
        eventsMap.put(new Integer(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED), new EventDescriptor(
                INPUT_METHOD_EVENT_MASK, InputMethodListener.class));
        eventsMap.put(new Integer(InputMethodEvent.CARET_POSITION_CHANGED), new EventDescriptor(
                INPUT_METHOD_EVENT_MASK, InputMethodListener.class));
        eventsMap.put(new Integer(InvocationEvent.INVOCATION_DEFAULT), new EventDescriptor(
                INVOCATION_EVENT_MASK, null));
        eventsMap.put(new Integer(ItemEvent.ITEM_STATE_CHANGED), new EventDescriptor(
                ITEM_EVENT_MASK, ItemListener.class));
        eventsMap.put(new Integer(TextEvent.TEXT_VALUE_CHANGED), new EventDescriptor(
                TEXT_EVENT_MASK, TextListener.class));
        eventsMap.put(new Integer(ActionEvent.ACTION_PERFORMED), new EventDescriptor(
                ACTION_EVENT_MASK, ActionListener.class));
        eventsMap.put(new Integer(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED), new EventDescriptor(
                ADJUSTMENT_EVENT_MASK, AdjustmentListener.class));
        converter = new EventConverter();
    
        this(event.target, event.id);
    
public AWTEvent(Object source, int id)
Instantiates a new AWT event with the specified object and type.

param
source the source Object.
param
id the event's type.

        super(source);
        this.id = id;
        consumed = false;
    
Methods Summary
protected voidconsume()
Consumes the AWTEvent.

        consumed = true;
    
java.awt.EventgetEvent()
Convert AWTEvent object to a corresponding (deprecated) Event object.

return
new Event object which is a converted AWTEvent object or null if the conversion is not possible


        if (id == ActionEvent.ACTION_PERFORMED) {
            ActionEvent ae = (ActionEvent)this;
            return converter.convertActionEvent(ae);

        } else if (id == AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED) {
            AdjustmentEvent ae = (AdjustmentEvent)this;
            return converter.convertAdjustmentEvent(ae);

            // ???AWT
            // } else if (id == ComponentEvent.COMPONENT_MOVED
            // && source instanceof Window) {
            // //the only type of Component events is COMPONENT_MOVED on window
            // ComponentEvent ce = (ComponentEvent) this;
            // return converter.convertComponentEvent(ce);

        } else if (id >= FocusEvent.FOCUS_FIRST && id <= FocusEvent.FOCUS_LAST) {
            // nothing to convert

            // ???AWT
            // } else if (id == ItemEvent.ITEM_STATE_CHANGED) {
            // ItemEvent ie = (ItemEvent) this;
            // return converter.convertItemEvent(ie);

        } else if (id == KeyEvent.KEY_PRESSED || id == KeyEvent.KEY_RELEASED) {
            KeyEvent ke = (KeyEvent)this;
            return converter.convertKeyEvent(ke);
        } else if (id >= MouseEvent.MOUSE_FIRST && id <= MouseEvent.MOUSE_LAST) {
            MouseEvent me = (MouseEvent)this;
            return converter.convertMouseEvent(me);
        } else if (id == WindowEvent.WINDOW_CLOSING || id == WindowEvent.WINDOW_ICONIFIED
                || id == WindowEvent.WINDOW_DEICONIFIED) {
            // nothing to convert
        } else {
            return null;
        }
        return new Event(source, id, null);
    
public intgetID()
Gets the event's type.

return
the event type ID.

        return id;
    
protected booleanisConsumed()
Checks whether or not this AWTEvent has been consumed.

return
true, if this AWTEvent has been consumed, false otherwise.

        return consumed;
    
public java.lang.StringparamString()
Returns a string representation of the AWTEvent state.

return
a string representation of the AWTEvent state.

        // nothing to implement: all event types must override this method
        return ""; //$NON-NLS-1$
    
public voidsetSource(java.lang.Object newSource)
Sets a new source for the AWTEvent.

param
newSource the new source Object for the AWTEvent.

        source = newSource;
    
public java.lang.StringtoString()
Returns a String representation of the AWTEvent.

return
the String representation of the AWTEvent.

        /*
         * The format is based on 1.5 release behavior which can be revealed by
         * the following code: AWTEvent event = new AWTEvent(new Component(){},
         * 1){}; System.out.println(event);
         */
        String name = ""; //$NON-NLS-1$

        if (source instanceof Component && (source != null)) {
            Component comp = (Component)getSource();
            name = comp.getName();
            if (name == null) {
                name = ""; //$NON-NLS-1$
            }
        }

        return (getClass().getName() + "[" + paramString() + "]" //$NON-NLS-1$ //$NON-NLS-2$
                + " on " + (name.length() > 0 ? name : source)); //$NON-NLS-1$