StocksMonitor 1.5.0

hirondelle.stocks.preferences
Class OptionPaneExceptionHandler

Object
  extended by Handler
      extended by OptionPaneExceptionHandler

public final class OptionPaneExceptionHandler
extends Handler

An implementation of a Java Logging API Handler which displays a short message to the user using a JOptionPane, and is intended only for Level.SEVERE messages.

The issue arises of how to inform the user in the case of a Level.SEVERE message : if all Handlers are purely textual, then in a graphical application it is not uncommon for the user to be unaware of the problem, since the textual output is not necessarily visible. This Handler addresses the issue by defining a graphical logging Handler, which will always get the user's attention by using a visual pop-up message.

This Handler is unusual for two reasons :

The content of the message is taken from LogRecord.getMessage(), which is usually a short piece of text. The intent is that this Handler present only the barest facts, and that the user refer to other text-based Handler tools for further information.

This Handler can be used both from the event dispatch thread, and from any other thread. Thus, it may be used by any worker thread which is experiencing difficulties.

Typically, this Handler is attached to the root Logger, and is thus inherited by all all other Loggers.


Constructor Summary
OptionPaneExceptionHandler()
          Construct this Handler with default settings.
 
Method Summary
static void attachToRootLogger()
          Add a OptionPaneExceptionHandler to the root Logger.
 void close()
          No-operation.
 void flush()
          No-operation.
 void publish(LogRecord aLogRecord)
          If aLogRecord satisfies Handler.isLoggable(java.util.logging.LogRecord), then a short message is displayed to the user using a JOptionPane.
 
Methods inherited from class Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionPaneExceptionHandler

public OptionPaneExceptionHandler()
Construct this Handler with default settings. These defaults should not be changed :

Method Detail

close

public void close()
No-operation.

Specified by:
close in class Handler

flush

public void flush()
No-operation.

Specified by:
flush in class Handler

publish

public void publish(LogRecord aLogRecord)
If aLogRecord satisfies Handler.isLoggable(java.util.logging.LogRecord), then a short message is displayed to the user using a JOptionPane.

The message is presented in a modal dialog, and will grab the focus.

Warning : if a SEVERE message is generated during startup, before the main window is displayed, then any pop-up message generated by this class will eventually be hidden behind the main window.

Specified by:
publish in class Handler

attachToRootLogger

public static void attachToRootLogger()
Add a OptionPaneExceptionHandler to the root Logger.

Typically, the Handler attached to the root Logger is inherited by all other Loggers.

Called both upon startup and when refreshing the logging.properties file. In the case of startup, it is best to call this method only after the main window is shown ; otherwise, it is likely that any startup error messages generated by this class will be hidden by the main window.


StocksMonitor 1.5.0

Copyright Hirondelle Systems - License - Generated 2008Jul12.10.53