Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ix.iface.util
Class CatchingActionListener

    java.lang.Object
      ix.iface.util.CatchingActionListener

All Implemented Interfaces:
  java.awt.event.ActionListener, java.util.EventListener

    public class CatchingActionListener

extends java.lang.Object
implements java.awt.event.ActionListener

An ActionListener that catches and reports exceptions. It can be used as a wrapper around a plain ActionListener or as a base for subclasses that redefine `innerActionPerformed(ActionEvent)`.

The static method `listener(ActionListener)` is a convenient way to wrap a listener that might be used more than once.

Field Summary
`protected java.awt.event.ActionListener` | `innerListener`
`(package private) static java.util.Map` | `listenerCache`

Constructor Summary
`protected` | `CatchingActionListener()` Constructs a catching listener without an inner listener.
`` | `CatchingActionListener(java.awt.event.ActionListener innerListener)` Constructs a catching listener around the specified inner listener.

Method Summary
`void` | `actionPerformed(java.awt.event.ActionEvent event)` Calls `innerActionPerformed(ActionEvent)` on the same event, but inside a `try-catch` statement that catches any exception or error thrown.
`java.awt.event.ActionListener` | `getInnerListener()` Returns the inner action-listener that is wrapped in this CatchingActionListener.
`void` | `handleException(java.awt.event.ActionEvent event, java.lang.Throwable except)` Called if the innerActionPerformed method throws an exception or error.
`protected void` | `innerActionPerformed(java.awt.event.ActionEvent event)` Called by `actionPerformed(ActionEvent)` inside a catch that will report any exceptions thrown.
`static java.awt.event.ActionListener` | `listener(java.awt.event.ActionListener inner)` Returns the outer listener, if any, that was recorded for the specified inner listener, or else constructs and records a new CatchingActionListener.
`static void` | `recordListener(java.awt.event.ActionListener inner, java.awt.event.ActionListener outer)` Records a specific outer listener for cases where it must be an instance of class other than CatchingActionListener, for instance a subclass.
`void` | `setInnerListener(java.awt.event.ActionListener innerListener)` Sets the inner action-listener that is wrapped in this CatchingActionListener.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### innerListener

    protected java.awt.event.ActionListener innerListener

### listenerCache

    static java.util.Map listenerCache

Constructor Detail

### CatchingActionListener

    public CatchingActionListener(java.awt.event.ActionListener innerListener)

  Constructs a catching listener around the specified inner listener.

### CatchingActionListener

    protected CatchingActionListener()

  Constructs a catching listener without an inner listener. This should be used only in subclasses that redefine the `innerActionPerformed(ActionEvent)` method or when `setInnerListener(ActionListener)` method will be called.

Method Detail

### getInnerListener

    public java.awt.event.ActionListener getInnerListener()

  Returns the inner action-listener that is wrapped in this CatchingActionListener.

### setInnerListener

    public void setInnerListener(java.awt.event.ActionListener innerListener)

  Sets the inner action-listener that is wrapped in this CatchingActionListener.

### actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent event)

  Calls `innerActionPerformed(ActionEvent)` on the same event, but inside a `try-catch` statement that catches any exception or error thrown. The ActionEvent and the exception or error are then passed to this object's handleException method after a call to `Debug.noteException(e)`.

  Note that the innerActionPerformed method define by this calls calls the inner listener's actionPerformed method; but that can be overridden in subclasses.

  Specified by:
    `actionPerformed` in interface `java.awt.event.ActionListener`
  See Also:
    `Debug.noteException(Throwable)`

### innerActionPerformed

    protected void innerActionPerformed(java.awt.event.ActionEvent event)

  Called by `actionPerformed(ActionEvent)` inside a catch that will report any exceptions thrown. This method just calls the inner listener's actionPerformed method, and it should be overridden in subclasses that do not use an inner listener.

### handleException

    public void handleException(java.awt.event.ActionEvent event,
                                java.lang.Throwable except)

  Called if the innerActionPerformed method throws an exception or error. This method puts up an error message dialog that displays the ActionEvent's action command and a description of the exception or error.

  See Also:
    `Debug.foldException(Throwable)`

### listener

    public static java.awt.event.ActionListener listener(java.awt.event.ActionListener inner)

  Returns the outer listener, if any, that was recorded for the specified inner listener, or else constructs and records a new CatchingActionListener. The listeners are recorded in a WeakHashMap.

### recordListener

    public static void recordListener(java.awt.event.ActionListener inner,
                                      java.awt.event.ActionListener outer)

  Records a specific outer listener for cases where it must be an instance of class other than CatchingActionListener, for instance a subclass.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD