|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
org.jdesktop.swingx.JXErrorDialog
public class JXErrorDialog
Common Error Dialog, suitable for representing information about
errors and exceptions happened in application. The common usage of the
JXErrorDialog
is to show collected data about the incident and
probably ask customer for a feedback. The data about the incident consists
from the title which will be displayed in the dialog header, short
description of the problem that will be immediately seen after dialog is
became visible, full description of the problem which will be visible after
user clicks "Details" button and Throwable that contains stack trace and
another usable information that may be displayed in the dialog.
There are two basic ways to use the JXErrorDialog. The first is to call one
of the standard static methods for displaying the error dialog. Here is a
basic example:
try {
//do some work
//some exception is thrown
} catch (Exception e) {
JXErrorDialog.showDialog(this, "Critical Error",
"<html><body>Some <b>critical error</b> has occured." +
" You may need to restart this application. Message #SC21." +
"</body></html>", e);
}
For the vast majority of use cases, the static methods should be sufficient and are recommended. However, for those few use cases requireing customizations, you can create and display a JXErrorDialog manually.
To ask user for feedback extend abstract class ErrorReporter
and
set your reporter using setReporter
method. Report button will
be added to the dialog automatically.
See MailErrorReporter
documentation for the
example of error reporting usage.
For example, to show simple JXErrorDialog
call
JXErrorDialog.showDialog(null, "Application Error",
"The application encountered the unexpected error,
please contact developers")
Internationalization is handled via a resource bundle or via the UIManager bidi orientation (usefull for right to left languages) is determined in the same way as the JOptionPane where the orientation of the parent component is picked. So when showDialog(Component cmp, ...) is invoked the component orientation of the error dialog will match the component orientation of cmp.
Nested Class Summary | |
---|---|
class |
JXErrorDialog.ReportAction
Action for report button |
Nested classes/interfaces inherited from class javax.swing.JDialog |
---|
JDialog.AccessibleJDialog |
Nested classes/interfaces inherited from class java.awt.Dialog |
---|
Dialog.AccessibleAWTDialog |
Nested classes/interfaces inherited from class java.awt.Window |
---|
Window.AccessibleAWTWindow |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JDialog |
---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JXErrorDialog(Dialog owner)
Create a new ErrorDialog with the given Dialog as the owner |
|
JXErrorDialog(Frame owner)
Create a new ErrorDialog with the given Frame as the owner |
Method Summary | |
---|---|
static Icon |
getDefaultErrorIcon()
|
static ErrorReporter |
getDefaultErrorReporter()
Returns the current reporting engine that will be used to report a problem if user clicks on 'Report' button or null if no reporting engine set. |
static Icon |
getDefaultWarningIcon()
|
Icon |
getErrorIcon()
Returns the Icon in use if the IncidentInfo is Level.SEVERE |
ErrorReporter |
getErrorReporter()
Returns the error reporter in use with this instance of JXErrorDialog. |
IncidentInfo |
getIncidentInfo()
Get curent dialog's IncidentInfo |
Action |
getReportAction()
|
static ErrorReporter |
getReporter()
Deprecated. Use getDefaultErrorReporter instead |
Icon |
getWarningIcon()
Returns the Icon in use if the IncidentInfo is not Level.SEVERE |
static void |
setDefaultErrorIcon(Icon icon)
Set the Icon to use as the default error icon for JXErrorDialog instances. |
static void |
setDefaultErrorReporter(ErrorReporter rep)
Set reporting engine which will handle error reporting if user clicks 'report' button. |
static void |
setDefaultWarningIcon(Icon icon)
Set the Icon to use as the default warning icon for JXErrorDialog instances. |
void |
setErrorIcon(Icon icon)
Specifies the icon to use if the IncidentInfo is Level.SEVERE |
void |
setErrorReporter(ErrorReporter rep)
Sets the ErrorReporter to use with this instance of JXErrorDialog. |
void |
setIncidentInfo(IncidentInfo info)
Sets the IncidentInfo for this dialog |
void |
setReportAction(Action action)
Specify the Action that will be executed to report an error/warning. |
static void |
setReporter(ErrorReporter rep)
Deprecated. Use setDefaultErrorReporter instead |
void |
setWarningIcon(Icon icon)
Specifies the icon to use if the IncidentInfo is not Level.SEVERE |
static void |
showDialog(Component owner,
IncidentInfo info)
Show the error dialog. |
static void |
showDialog(Component owner,
String title,
String errorMessage)
Show the error dialog. |
static void |
showDialog(Component owner,
String title,
String errorMessage,
String details)
Show the error dialog. |
static void |
showDialog(Component owner,
String title,
String errorMessage,
Throwable e)
Constructs and shows the error dialog for the given exception. |
static void |
showDialog(Component owner,
String title,
Throwable e)
Constructs and shows the error dialog for the given exception. |
Methods inherited from class java.awt.Dialog |
---|
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JXErrorDialog(Frame owner)
owner
- Owner of this error dialog.public JXErrorDialog(Dialog owner)
owner
- Owner of this error dialog.Method Detail |
---|
public void setIncidentInfo(IncidentInfo info)
info
- IncidentInfo that incorporates all the details about the errorpublic IncidentInfo getIncidentInfo()
IncidentInfo
assigned to this dialogpublic void setErrorReporter(ErrorReporter rep)
rep
- if null, the default error reporter is usedpublic ErrorReporter getErrorReporter()
public void setErrorIcon(Icon icon)
icon
- the Icon to use. If null, the default error icon will be usedpublic Icon getErrorIcon()
public void setWarningIcon(Icon icon)
icon
- the Icon to use. If null, the default warning icon will be usedpublic Icon getWarningIcon()
public void setReportAction(Action action)
action
- The Action to execute if the user attempts to report a problempublic Action getReportAction()
public static void showDialog(Component owner, String title, Throwable e)
owner
- Owner of this error dialog. Determines the Window in which the dialog
is displayed; if the owner
has
no Window
, a default Frame
is usedtitle
- Title of the error dialoge
- Exception that contains information about the error cause and stack tracepublic static void showDialog(Component owner, String title, String errorMessage, Throwable e)
owner
- Owner of this error dialog. Determines the Window in which the dialog
is displayed; if the owner
has
no Window
, a default Frame
is usedtitle
- Title of the error dialogerrorMessage
- Message for the error dialoge
- Exception that contains information about the error cause and stack tracepublic static void showDialog(Component owner, String title, String errorMessage, String details)
owner
- Owner of this error dialog. Determines the Window in which the dialog
is displayed; if the owner
has
no Window
, a default Frame
is usedtitle
- Title of the error dialogerrorMessage
- Message for the error dialogdetails
- Details to be shown in the detail section of the dialog. This can be null
if you do not want to display the details section of the dialog.public static void showDialog(Component owner, String title, String errorMessage)
owner
- Owner of this error dialog. Determines the Window in which the dialog
is displayed; if the owner
has
no Window
, a default Frame
is usedtitle
- Title of the error dialogerrorMessage
- Message for the error dialogpublic static void showDialog(Component owner, IncidentInfo info)
owner
- Owner of this error dialog. Determines the Window in which the dialog
is displayed; if the owner
has
no Window
, a default Frame
is usedinfo
- IncidentInfo
that incorporates all the information about the errorpublic static ErrorReporter getReporter()
getDefaultErrorReporter
instead
null
if no reporting engine set.
public static void setReporter(ErrorReporter rep)
setDefaultErrorReporter
instead
rep
- ErrorReporter
to be used or null
to turn reporting facility off.public static ErrorReporter getDefaultErrorReporter()
null
if no reporting engine set.
public static void setDefaultErrorReporter(ErrorReporter rep)
rep
- ErrorReporter
to be used or null
to turn reporting facility off.public static void setDefaultErrorIcon(Icon icon)
icon
- the Icon to use as the default error iconpublic static Icon getDefaultErrorIcon()
public static void setDefaultWarningIcon(Icon icon)
icon
- the Icon to use as the default warning iconpublic static Icon getDefaultWarningIcon()
|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |