KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > thinlet > drafts > ExceptionDialog


1 package thinlet.drafts;
2
3 import java.io.*;
4 import thinlet.*;
5
6 /**
7  *
8  */

9 public class ExceptionDialog {
10     
11     /**
12      *
13      */

14     public ExceptionDialog(Thinlet thinlet, Throwable JavaDoc throwable) {
15         try {
16             Object JavaDoc dialog = thinlet.parse("/thinlet/drafts/exceptiondialog.xml", this);
17             thinlet.setString(dialog, "text", throwable.getClass().getName());
18             thinlet.setString(thinlet.find(dialog, "message"), "text", throwable.getMessage());
19             StringWriter stacktrace = new StringWriter();
20             throwable.printStackTrace(new PrintWriter(stacktrace));
21             thinlet.setString(thinlet.find(dialog, "stacktrace"), "text",
22                 stacktrace.toString().replace('\r', ' ').replace('\t', ' '));
23             thinlet.add(dialog);
24         } catch (Exception JavaDoc exc) { exc.printStackTrace(); }
25     }
26     
27     /**
28      *
29      */

30     public void close(Thinlet thinlet, Object JavaDoc dialog) {
31         thinlet.remove(dialog);
32     }
33 }
Popular Tags