org.geotools.gui.swing
Class ExceptionMonitor

java.lang.Object
  extended byorg.geotools.gui.swing.ExceptionMonitor

public final class ExceptionMonitor
extends java.lang.Object

Utility which enables exception messages to be displayed in a Swing component. The standard Exception class contains methods which write the exception to the error console. This class adds static methods which make the message, and eventually the exception trace, appear in a viewer component.

 

 

Since:
2.0
Version:
$Id: ExceptionMonitor.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Method Summary
static void main(java.lang.String[] args)
          Display a dummy exception.
static void paintStackTrace(java.awt.Graphics2D graphics, java.awt.Rectangle widgetBounds, java.lang.Throwable exception)
          Writes the specified exception trace in the specified graphics context.
static void show(java.awt.Component owner, java.lang.Throwable exception)
          Displays an error message for the specified exception.
static void show(java.awt.Component owner, java.lang.Throwable exception, java.lang.String message)
          Displays an error message for the specified exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

show

public static void show(java.awt.Component owner,
                        java.lang.Throwable exception)
Displays an error message for the specified exception. Note that this method can be called from any thread (not necessarily the Swing thread).

Parameters:
owner - Component in which the exception is produced, or if unknown.
exception - Exception which has been thrown and is to be reported to the user.

show

public static void show(java.awt.Component owner,
                        java.lang.Throwable exception,
                        java.lang.String message)
Displays an error message for the specified exception. Note that this method can be called from any thread (not necessarily the Swing thread).

Parameters:
owner - Component in which the exception is produced, or if unknown.
exception - Exception which has been thrown and is to be reported to the user.
message - Message to display. If this parameter is null, then Throwable.getLocalizedMessage() will be called to obtain the message.

paintStackTrace

public static void paintStackTrace(java.awt.Graphics2D graphics,
                                   java.awt.Rectangle widgetBounds,
                                   java.lang.Throwable exception)
Writes the specified exception trace in the specified graphics context. This method is useful when an exception has occurred inside a Component.paint(java.awt.Graphics) method and we want to write it rather than leaving an empty window.

Parameters:
graphics - Graphics context in which to write exception. The graphics context should be in its initial state (default affine transform, default colour, etc...)
widgetBounds - Size of the trace which was being drawn.
exception - Exception whose trace we want to write.

main

public static void main(java.lang.String[] args)
Display a dummy exception. This method is provided only as an easy way to test the dialog appearance from the command line.



Copyright © GeoTools. All Rights Reserved.