01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.gui.components;
20:
21: import java.awt.Component;
22: import java.awt.Dialog;
23: import java.awt.Frame;
24:
25: import com.jeta.open.gui.framework.JETADialog;
26: import com.jeta.open.gui.utils.JETAToolbox;
27: import com.jeta.open.i18n.I18N;
28:
29: /**
30: * This is a utility dialog that can be used to display an Exception.
31: *
32: * @author Jeff Tassin
33: */
34: public class TSErrorDialog2 extends JETADialog {
35: /** message to be prepended to error */
36: private String m_msg;
37:
38: /**
39: * ctor
40: */
41: public TSErrorDialog2(Dialog owner, boolean bmodal) {
42: super (owner, bmodal);
43: }
44:
45: /**
46: * ctor
47: */
48: public TSErrorDialog2(Frame owner, boolean bmodal) {
49: super (owner, bmodal);
50: }
51:
52: public static TSErrorDialog2 createDialog(Component owner,
53: String caption, String errormsg, Throwable e) {
54: TSErrorDialog2 dlg = (TSErrorDialog2) JETAToolbox.createDialog(
55: TSErrorDialog2.class, owner, true);
56: dlg.setTitle(I18N.getLocalizedMessage("Error"));
57: dlg.initialize(errormsg, e);
58: if (caption != null)
59: dlg.showErrorIcon(caption);
60:
61: dlg.setSize(dlg.getPreferredSize());
62: return dlg;
63: }
64:
65: /**
66: * Initializes the dialog with the exception
67: */
68: public void initialize(String msg, Throwable e) {
69: setTitle(I18N.getLocalizedMessage("Error"));
70: TSErrorPanel2 panel = new TSErrorPanel2();
71: panel.initialize(msg, e);
72: setPrimaryPanel(panel);
73: showErrorIcon(I18N.getLocalizedMessage("Error"));
74: }
75:
76: /**
77: * Shows an error message 'title' with an error icon at top of panel
78: */
79: public void showErrorIcon(String msg) {
80: TSErrorPanel2 panel = (TSErrorPanel2) getPrimaryPanel();
81: if (panel != null) {
82: panel.showErrorIcon(msg);
83: }
84: }
85: }
|