AWTEventMonitor (Java SE 13 & JDK 13 )
Description: declaration: module: jdk.accessibility, package: com.sun.java.accessibility.util, class: AWTEventMonitor
Keywords: com.sun.java.accessibility.util.AWTEventMonitor class

Module jdk.accessibility
Package com.sun.java.accessibility.util

# Class AWTEventMonitor

java.lang.Object
com.sun.java.accessibility.util.AWTEventMonitor

Direct Known Subclasses:
  `SwingEventMonitor`

    public class AWTEventMonitor
    extends Object

The `AWTEventMonitor` implements a suite of listeners that are conditionally installed on every AWT component instance in the Java Virtual Machine. The events captured by these listeners are made available through a unified set of listeners supported by `AWTEventMonitor`. With this, all the individual events on each of the AWT component instances are funneled into one set of listeners broken down by category (see `EventID` for the categories).

This class depends upon `EventQueueMonitor`, which provides the base level support for capturing the top-level containers as they are created.

- ## Field Summary

  Fields
  Modifier and Type | Field | Description
  --- | --- | ---
  `protected static ActionListener` | `actionListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static AdjustmentListener` | `adjustmentListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static ComponentListener` | `componentListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static Component` | `componentWithFocus` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused; to get the component with focus use the getComponentWithFocus method.
  `protected static ContainerListener` | `containerListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static FocusListener` | `focusListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static ItemListener` | `itemListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static KeyListener` | `keyListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static MouseListener` | `mouseListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static MouseMotionListener` | `mouseMotionListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static TextListener` | `textListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.
  `protected static WindowListener` | `windowListener` | Deprecated, for removal: This API element is subject to removal in a future version. This field is unused.

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `AWTEventMonitor()` |

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `static void` | `addActionListener​(ActionListener l)` | Adds the specified listener to receive all `ACTION` events on each component instance in the Java Virtual Machine when they occur.
  `static void` | `addAdjustmentListener​(AdjustmentListener l)` | Adds the specified listener to receive all `ADJUSTMENT` events on each component instance in the Java Virtual Machine when they occur.
  `static void` | `addComponentListener​(ComponentListener l)` | Adds the specified listener to receive all `COMPONENT` events on each component instance in the Java Virtual Machine as they occur.
  `static void` | `addContainerListener​(ContainerListener l)` | Adds the specified listener to receive all `CONTAINER` events on each component instance in the Java Virtual Machine as they occur.
  `static void` | `addFocusListener​(FocusListener l)` | Adds the specified listener to receive all `FOCUS` events on each component instance in the Java Virtual Machine when they occur.
  `static void` | `addItemListener​(ItemListener l)` | Adds the specified listener to receive all `ITEM` events on each component instance in the Java Virtual Machine when they occur.
  `static void` | `addKeyListener​(KeyListener l)` | Adds the specified listener to receive all `KEY` events on each component instance in the Java Virtual Machine when they occur.
  `static void` | `addMouseListener​(MouseListener l)` | Adds the specified listener to receive all `MOUSE` events on each component instance in the Java Virtual Machine when they occur.
  `static void` | `addMouseMotionListener​(MouseMotionListener l)` | Adds the specified listener to receive all mouse `MOTION` events on each component instance in the Java Virtual Machine when they occur.
  `static void` | `addTextListener​(TextListener l)` | Adds the specified listener to receive all `TEXT` events on each component instance in the Java Virtual Machine when they occur.
  `static void` | `addWindowListener​(WindowListener l)` | Adds the specified listener to receive all `WINDOW` events on each component instance in the Java Virtual Machine when they occur.
  `static Component` | `getComponentWithFocus()` | Returns the component that currently has keyboard focus.
  `static void` | `removeActionListener​(ActionListener l)` | Removes the specified listener so it no longer receives `ACTION` events when they occur.
  `static void` | `removeAdjustmentListener​(AdjustmentListener l)` | Removes the specified listener so it no longer receives `ADJUSTMENT` events when they occur.
  `static void` | `removeComponentListener​(ComponentListener l)` | Removes the specified listener so it no longer receives `COMPONENT` events when they occur.
  `static void` | `removeContainerListener​(ContainerListener l)` | Removes the specified listener so it no longer receives `CONTAINER` events when they occur.
  `static void` | `removeFocusListener​(FocusListener l)` | Removes the specified listener so it no longer receives `FOCUS` events when they occur.
  `static void` | `removeItemListener​(ItemListener l)` | Removes the specified listener so it no longer receives `ITEM` events when they occur.
  `static void` | `removeKeyListener​(KeyListener l)` | Removes the specified listener so it no longer receives `KEY` events when they occur.
  `static void` | `removeMouseListener​(MouseListener l)` | Removes the specified listener so it no longer receives `MOUSE` events when they occur.
  `static void` | `removeMouseMotionListener​(MouseMotionListener l)` | Removes the specified listener so it no longer receives `MOTION` events when they occur.
  `static void` | `removeTextListener​(TextListener l)` | Removes the specified listener so it no longer receives `TEXT` events when they occur.
  `static void` | `removeWindowListener​(WindowListener l)` | Removes the specified listener so it no longer receives `WINDOW` events when they occur.

  ### Methods declared in class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### componentWithFocus

    @Deprecated(since="8", forRemoval=true) protected static Component componentWithFocus
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused; to get the component with focus use the getComponentWithFocus method.
    The current component with keyboard focus.
    See Also:
      `getComponentWithFocus()`

  - ### componentListener

    @Deprecated(since="8", forRemoval=true) protected static ComponentListener componentListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered ComponentListener classes.
    See Also:
      `addComponentListener(java.awt.event.ComponentListener)`, `removeComponentListener(java.awt.event.ComponentListener)`

  - ### containerListener

    @Deprecated(since="8", forRemoval=true) protected static ContainerListener containerListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered ContainerListener classes.
    See Also:
      `addContainerListener(java.awt.event.ContainerListener)`, `removeContainerListener(java.awt.event.ContainerListener)`

  - ### focusListener

    @Deprecated(since="8", forRemoval=true) protected static FocusListener focusListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered FocusListener classes.
    See Also:
      `addFocusListener(java.awt.event.FocusListener)`, `removeFocusListener(java.awt.event.FocusListener)`

  - ### keyListener

    @Deprecated(since="8", forRemoval=true) protected static KeyListener keyListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered KeyListener classes.
    See Also:
      `addKeyListener(java.awt.event.KeyListener)`, `removeKeyListener(java.awt.event.KeyListener)`

  - ### mouseListener

    @Deprecated(since="8", forRemoval=true) protected static MouseListener mouseListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered MouseListener classes.
    See Also:
      `addMouseListener(java.awt.event.MouseListener)`, `removeMouseListener(java.awt.event.MouseListener)`

  - ### mouseMotionListener

    @Deprecated(since="8", forRemoval=true) protected static MouseMotionListener mouseMotionListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered MouseMotionListener classes.
    See Also:
      `addMouseMotionListener(java.awt.event.MouseMotionListener)`, `removeMouseMotionListener(java.awt.event.MouseMotionListener)`

  - ### windowListener

    @Deprecated(since="8", forRemoval=true) protected static WindowListener windowListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered WindowListener classes.
    See Also:
      `addWindowListener(java.awt.event.WindowListener)`, `removeWindowListener(java.awt.event.WindowListener)`

  - ### actionListener

    @Deprecated(since="8", forRemoval=true) protected static ActionListener actionListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered ActionListener classes.
    See Also:
      `addActionListener(java.awt.event.ActionListener)`, `removeActionListener(java.awt.event.ActionListener)`

  - ### adjustmentListener

    @Deprecated(since="8", forRemoval=true) protected static AdjustmentListener adjustmentListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered AdjustmentListener classes.
    See Also:
      `addAdjustmentListener(java.awt.event.AdjustmentListener)`, `removeAdjustmentListener(java.awt.event.AdjustmentListener)`

  - ### itemListener

    @Deprecated(since="8", forRemoval=true) protected static ItemListener itemListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered ItemListener classes.
    See Also:
      `addItemListener(java.awt.event.ItemListener)`, `removeItemListener(java.awt.event.ItemListener)`

  - ### textListener

    @Deprecated(since="8", forRemoval=true) protected static TextListener textListener
    Deprecated, for removal: This API element is subject to removal in a future version.
    This field is unused.
    The current list of registered TextListener classes.
    See Also:
      `addTextListener(java.awt.event.TextListener)`, `removeTextListener(java.awt.event.TextListener)`

- ## Constructor Details

  - ### AWTEventMonitor

    public AWTEventMonitor()

- ## Method Details

  - ### getComponentWithFocus

    public static Component getComponentWithFocus()
    Returns the component that currently has keyboard focus. The return value can be null.
    Returns:
      the component that has keyboard focus

  - ### addComponentListener

    public static void addComponentListener​(ComponentListener l)
    Adds the specified listener to receive all `COMPONENT` events on each component instance in the Java Virtual Machine as they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeComponentListener(java.awt.event.ComponentListener)`

  - ### removeComponentListener

    public static void removeComponentListener​(ComponentListener l)
    Removes the specified listener so it no longer receives `COMPONENT` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addComponentListener(java.awt.event.ComponentListener)`

  - ### addContainerListener

    public static void addContainerListener​(ContainerListener l)
    Adds the specified listener to receive all `CONTAINER` events on each component instance in the Java Virtual Machine as they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeContainerListener(java.awt.event.ContainerListener)`

  - ### removeContainerListener

    public static void removeContainerListener​(ContainerListener l)
    Removes the specified listener so it no longer receives `CONTAINER` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addContainerListener(java.awt.event.ContainerListener)`

  - ### addFocusListener

    public static void addFocusListener​(FocusListener l)
    Adds the specified listener to receive all `FOCUS` events on each component instance in the Java Virtual Machine when they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeFocusListener(java.awt.event.FocusListener)`

  - ### removeFocusListener

    public static void removeFocusListener​(FocusListener l)
    Removes the specified listener so it no longer receives `FOCUS` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addFocusListener(java.awt.event.FocusListener)`

  - ### addKeyListener

    public static void addKeyListener​(KeyListener l)
    Adds the specified listener to receive all `KEY` events on each component instance in the Java Virtual Machine when they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeKeyListener(java.awt.event.KeyListener)`

  - ### removeKeyListener

    public static void removeKeyListener​(KeyListener l)
    Removes the specified listener so it no longer receives `KEY` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addKeyListener(java.awt.event.KeyListener)`

  - ### addMouseListener

    public static void addMouseListener​(MouseListener l)
    Adds the specified listener to receive all `MOUSE` events on each component instance in the Java Virtual Machine when they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeMouseListener(java.awt.event.MouseListener)`

  - ### removeMouseListener

    public static void removeMouseListener​(MouseListener l)
    Removes the specified listener so it no longer receives `MOUSE` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addMouseListener(java.awt.event.MouseListener)`

  - ### addMouseMotionListener

    public static void addMouseMotionListener​(MouseMotionListener l)
    Adds the specified listener to receive all mouse `MOTION` events on each component instance in the Java Virtual Machine when they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeMouseMotionListener(java.awt.event.MouseMotionListener)`

  - ### removeMouseMotionListener

    public static void removeMouseMotionListener​(MouseMotionListener l)
    Removes the specified listener so it no longer receives `MOTION` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addMouseMotionListener(java.awt.event.MouseMotionListener)`

  - ### addWindowListener

    public static void addWindowListener​(WindowListener l)
    Adds the specified listener to receive all `WINDOW` events on each component instance in the Java Virtual Machine when they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeWindowListener(java.awt.event.WindowListener)`

  - ### removeWindowListener

    public static void removeWindowListener​(WindowListener l)
    Removes the specified listener so it no longer receives `WINDOW` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addWindowListener(java.awt.event.WindowListener)`

  - ### addActionListener

    public static void addActionListener​(ActionListener l)
    Adds the specified listener to receive all `ACTION` events on each component instance in the Java Virtual Machine when they occur.

    Note: This listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeActionListener(java.awt.event.ActionListener)`

  - ### removeActionListener

    public static void removeActionListener​(ActionListener l)
    Removes the specified listener so it no longer receives `ACTION` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addActionListener(java.awt.event.ActionListener)`

  - ### addAdjustmentListener

    public static void addAdjustmentListener​(AdjustmentListener l)
    Adds the specified listener to receive all `ADJUSTMENT` events on each component instance in the Java Virtual Machine when they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeAdjustmentListener(java.awt.event.AdjustmentListener)`

  - ### removeAdjustmentListener

    public static void removeAdjustmentListener​(AdjustmentListener l)
    Removes the specified listener so it no longer receives `ADJUSTMENT` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addAdjustmentListener(java.awt.event.AdjustmentListener)`

  - ### addItemListener

    public static void addItemListener​(ItemListener l)
    Adds the specified listener to receive all `ITEM` events on each component instance in the Java Virtual Machine when they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeItemListener(java.awt.event.ItemListener)`

  - ### removeItemListener

    public static void removeItemListener​(ItemListener l)
    Removes the specified listener so it no longer receives `ITEM` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addItemListener(java.awt.event.ItemListener)`

  - ### addTextListener

    public static void addTextListener​(TextListener l)
    Adds the specified listener to receive all `TEXT` events on each component instance in the Java Virtual Machine when they occur.

    Note: this listener is automatically added to all component instances created after this method is called. In addition, it is only added to component instances that support this listener type.

    Parameters:
      `l` - the listener to add
    See Also:
      `removeTextListener(java.awt.event.TextListener)`

  - ### removeTextListener

    public static void removeTextListener​(TextListener l)
    Removes the specified listener so it no longer receives `TEXT` events when they occur.
    Parameters:
      `l` - the listener to remove
    See Also:
      `addTextListener(java.awt.event.TextListener)`