Skip to content

The code in this repository creates a Java Swing exception display dialog and an example JFrame to trigger the exception display dialog.

Notifications You must be signed in to change notification settings

ggleblanc2/error-display-dialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Error Display Dialog

A recent Stack Overflow question prompted me to create an example GUI to display a Java Exception. I thought it might be useful to create an error display dialog to display a Java Exception in a Swing GUI.

So i created the following test GUI.

Error Display Example

Left-clicking the button brings up the error display dialog.

Error Display Dialog

If you’re not familiar with Java Swing, Oracle has an excellent tutorial to get you started, Creating a GUI With Swing. Skip the Netbeans section.

To use the error display dialog, copy the ErrorDisplayDialog class into your project. The class requires no other classes.

Whenever you create a try-catch block in your Swing GUI, instead of coding this:

		try {
			// Code that could throw an Exception
		} catch (SQLException e) {
			e.printStackTrace();
		}	

You code this:

		try {
			// Code that could throw an Exception
		} catch (SQLException e) {
			new ErrorDisplayDialog(frame, "Error Message Dialog", e);
		}	

I used an SQLException in my testing, but the display dialog should work with any Exception.

About

The code in this repository creates a Java Swing exception display dialog and an example JFrame to trigger the exception display dialog.

Topics

Resources

Stars

Watchers

Forks

Languages