KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > gui > ErrorHandler


1 package sellwin.gui;
2
3 import sellwin.utils.*;
4 import javax.swing.*;
5 import java.awt.*;
6
7 // SellWin http://sourceforge.net/projects/sellwincrm
8
//Contact support@open-app.com for commercial help with SellWin
9
//This software is provided "AS IS", without a warranty of any kind.
10

11 /**
12  * This class provides a simple error display handler
13  * for the GUI
14  */

15 public class ErrorHandler {
16
17     /**
18      * show a popup error dialog
19      * @param parent the container for this popup
20      * @param g the exception to display in this popup
21      */

22     public final static void show(Component parent, Exception JavaDoc g) {
23         LogWrite.write(g);
24         g.printStackTrace();
25         JOptionPane.showMessageDialog(
26             parent,
27             g.getMessage(),
28             "ERROR",
29             JOptionPane.ERROR_MESSAGE);
30     }
31
32     /**
33      * show a popup error dialog
34      * @param parent the container for this popup
35      * @param g the exception to display in this popup
36      * @param str a user supplied string to display as well as the err
37      */

38     public final static void show(Component parent, Exception JavaDoc g, String JavaDoc str) {
39         LogWrite.write(g);
40         g.printStackTrace();
41         JOptionPane.showMessageDialog(
42             parent,
43             g.getMessage() + ":" + str,
44             "ERROR",
45             JOptionPane.ERROR_MESSAGE);
46     }
47 }
48
Popular Tags