/Users/lyon/j4p/src/classUtils/pack/util/swing/JExceptionPane.java
|
1 package classUtils.pack.util.swing;
2
3 import java.awt.Component;
4 import java.io.ByteArrayOutputStream;
5 import java.io.PrintStream;
6
7 import javax.swing.Icon;
8 import javax.swing.JOptionPane;
9
10 /**
11 * An extension of JOptionPane to show exception-related messages
12 *
13 * @author cris
14 */
15 public class JExceptionPane extends JOptionPane {
16
17 /**
18 * Shows the exception in a dialog
19 */
20 public static void showExceptionDialog(
21 Component parent,
22 String title,
23 Throwable e) {
24 ByteArrayOutputStream os = new ByteArrayOutputStream();
25 PrintStream ps = new PrintStream(os);
26 e.printStackTrace(ps);
27 showMessageDialog(
28 parent,
29 os.toString(),
30 title,
31 JOptionPane.ERROR_MESSAGE
32 );
33 }
34
35 public static void showExceptionDialog(
36 Component parent,
37 Throwable e) {
38 showExceptionDialog(parent, "Exception occurred", e);
39 }
40
41 }
42