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
A wrapper to put around an ActionListener to catch any exceptions
or errors the listener throws and report them to the user.
Method Summary |
void |
actionPerformed(java.awt.event.ActionEvent event)
Calls the inner listener's ActionPerformed method on the same
event, but inside a try-catch statement that
catches any exception or error thrown. |
static java.lang.String |
description(java.lang.Throwable t)
Returns a description suitable for display in a dialog. |
void |
handleException(java.awt.event.ActionEvent event,
java.lang.Throwable except)
Called if the inner listener's ActionPerformed method throws
an exception or error. |
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. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
innerListener
java.awt.event.ActionListener innerListener
listenerCache
static java.util.Map listenerCache
CatchingActionListener
public CatchingActionListener(java.awt.event.ActionListener innerListener)
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
- Calls the inner listener's ActionPerformed method 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)
.
- Specified by:
actionPerformed
in interface java.awt.event.ActionListener
- See Also:
Debug.noteException(Throwable)
handleException
public void handleException(java.awt.event.ActionEvent event,
java.lang.Throwable except)
- Called if the inner listener's ActionPerformed method throws
an exception or error. This method puts up an error message dialog
that displays the ActionEvent's action command and a description
or the exception or error.
description
public static java.lang.String description(java.lang.Throwable t)
- Returns a description suitable for display in a dialog.
Because an error or exception's message is not always sufficiently
meaningful on its own, it is prefixed by the class name (minus
the package name). Long messages are split into lines.
- See Also:
Strings.foldLongLine(String)
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.