KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > poa > gui > beans > MessageDialog


1 package org.jacorb.poa.gui.beans;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22  
23 /**
24  * A Message Dialog Box
25  *
26  * @author Reimo Tiedemann, FU Berlin
27  * @version 1.0, 05/10/99, RT
28  */

29 public class MessageDialog extends java.awt.Dialog JavaDoc
30     implements CloseButtonPanelController, java.awt.event.WindowListener JavaDoc {
31     private String JavaDoc message = "";
32     private int xPos = 0;
33     private int yPos = 0;
34     private CloseButtonPanel ivjButtonPanel = null;
35     private java.awt.Panel JavaDoc ivjContentsPane = null;
36     private java.awt.Label JavaDoc ivjMessageLabel = null;
37     private java.awt.Panel JavaDoc ivjWorkPanel = null;
38 /**
39  * Constructor
40  * @param parent Symbol
41  */

42 /* WARNING: THIS METHOD WILL BE REGENERATED. */
43 public MessageDialog(java.awt.Frame JavaDoc parent) {
44     super(parent);
45     initialize();
46 }
47 /**
48  * MessageDialog constructor comment.
49  * @param parent java.awt.Frame
50  * @param title java.lang.String
51  */

52 public MessageDialog(java.awt.Frame JavaDoc parent, String JavaDoc title) {
53     super(parent, title);
54 }
55 public MessageDialog(java.awt.Frame JavaDoc parent, String JavaDoc title, String JavaDoc _message) {
56     super(parent, title);
57     message = _message;
58     xPos = parent.getBounds().x + parent.getBounds().width/4;
59     yPos = parent.getBounds().y + parent.getBounds().height/3;
60     initialize();
61 }
62 /**
63  * MessageDialog constructor comment.
64  * @param parent java.awt.Frame
65  * @param title java.lang.String
66  * @param modal boolean
67  */

68 public MessageDialog(java.awt.Frame JavaDoc parent, String JavaDoc title, boolean modal) {
69     super(parent, title, modal);
70 }
71 /**
72  * MessageDialog constructor comment.
73  * @param parent java.awt.Frame
74  * @param modal boolean
75  */

76 public MessageDialog(java.awt.Frame JavaDoc parent, boolean modal) {
77     super(parent, modal);
78 }
79 public void _actionCloseButtonPressed() {
80     dispose();
81 }
82 /**
83  * connEtoC1: (MessageDialog.window.windowClosing(java.awt.event.WindowEvent) --> MessageDialog.dispose()V)
84  * @param arg1 java.awt.event.WindowEvent
85  */

86 /* WARNING: THIS METHOD WILL BE REGENERATED. */
87 private void connEtoC1(java.awt.event.WindowEvent JavaDoc arg1) {
88     try {
89         // user code begin {1}
90
// user code end
91
this.dispose();
92         // user code begin {2}
93
// user code end
94
} catch (java.lang.Throwable JavaDoc ivjExc) {
95         // user code begin {3}
96
// user code end
97
handleException(ivjExc);
98     }
99 }
100 /**
101  * Return the ButtonPanel property value.
102  * @return org.jacorb.poa.gui.beans.CloseButtonPanel
103  */

104 /* WARNING: THIS METHOD WILL BE REGENERATED. */
105 private CloseButtonPanel getButtonPanel() {
106     if (ivjButtonPanel == null) {
107         try {
108             ivjButtonPanel = new org.jacorb.poa.gui.beans.CloseButtonPanel();
109             ivjButtonPanel.setName("ButtonPanel");
110             // user code begin {1}
111
// user code end
112
} catch (java.lang.Throwable JavaDoc ivjExc) {
113             // user code begin {2}
114
// user code end
115
handleException(ivjExc);
116         }
117     };
118     return ivjButtonPanel;
119 }
120 /**
121  * Return the ContentsPane property value.
122  * @return java.awt.Panel
123  */

124 /* WARNING: THIS METHOD WILL BE REGENERATED. */
125 private java.awt.Panel JavaDoc getContentsPane() {
126     if (ivjContentsPane == null) {
127         try {
128             ivjContentsPane = new java.awt.Panel JavaDoc();
129             ivjContentsPane.setName("ContentsPane");
130             ivjContentsPane.setLayout(new java.awt.BorderLayout JavaDoc());
131             getContentsPane().add(getButtonPanel(), "South");
132             getContentsPane().add(getWorkPanel(), "Center");
133             // user code begin {1}
134
// user code end
135
} catch (java.lang.Throwable JavaDoc ivjExc) {
136             // user code begin {2}
137
// user code end
138
handleException(ivjExc);
139         }
140     };
141     return ivjContentsPane;
142 }
143 /**
144  * Return the MessageLabel property value.
145  * @return java.awt.Label
146  */

147 /* WARNING: THIS METHOD WILL BE REGENERATED. */
148 private java.awt.Label JavaDoc getMessageLabel() {
149     if (ivjMessageLabel == null) {
150         try {
151             ivjMessageLabel = new java.awt.Label JavaDoc();
152             ivjMessageLabel.setName("MessageLabel");
153             ivjMessageLabel.setAlignment(java.awt.Label.CENTER);
154             ivjMessageLabel.setText("Message");
155             ivjMessageLabel.setBackground(java.awt.SystemColor.control);
156             // user code begin {1}
157
// user code end
158
} catch (java.lang.Throwable JavaDoc ivjExc) {
159             // user code begin {2}
160
// user code end
161
handleException(ivjExc);
162         }
163     };
164     return ivjMessageLabel;
165 }
166 /**
167  * Return the WorkPanel property value.
168  * @return java.awt.Panel
169  */

170 /* WARNING: THIS METHOD WILL BE REGENERATED. */
171 private java.awt.Panel JavaDoc getWorkPanel() {
172     if (ivjWorkPanel == null) {
173         try {
174             ivjWorkPanel = new java.awt.Panel JavaDoc();
175             ivjWorkPanel.setName("WorkPanel");
176             ivjWorkPanel.setLayout(new java.awt.BorderLayout JavaDoc());
177             getWorkPanel().add(getMessageLabel(), "Center");
178             // user code begin {1}
179
// user code end
180
} catch (java.lang.Throwable JavaDoc ivjExc) {
181             // user code begin {2}
182
// user code end
183
handleException(ivjExc);
184         }
185     };
186     return ivjWorkPanel;
187 }
188 /**
189  * Called whenever the part throws an exception.
190  * @param exception java.lang.Throwable
191  */

192 private void handleException(Throwable JavaDoc exception) {
193
194     /* Uncomment the following lines to print uncaught exceptions to stdout */
195     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
196
// exception.printStackTrace(System.out);
197
}
198 /**
199  * Initializes connections
200  */

201 /* WARNING: THIS METHOD WILL BE REGENERATED. */
202 private void initConnections() {
203     // user code begin {1}
204
// user code end
205
this.addWindowListener(this);
206 }
207 /**
208  * Initialize the class.
209  */

210 /* WARNING: THIS METHOD WILL BE REGENERATED. */
211 private void initialize() {
212     // user code begin {1}
213
// user code end
214
setName("MessageDialog");
215     setLayout(new java.awt.BorderLayout JavaDoc());
216     setBackground(java.awt.SystemColor.control);
217     setSize(420, 120);
218     setModal(true);
219     add(getContentsPane(), "Center");
220     initConnections();
221     // user code begin {2}
222
getButtonPanel()._init(this, " OK ");
223     setLocation(xPos, yPos);
224     getMessageLabel().setText(message);
225     // user code end
226
}
227 /**
228  * main entrypoint - starts the part when it is run as an application
229  * @param args java.lang.String[]
230  */

231 public static void main(java.lang.String JavaDoc[] args) {
232     try {
233         MessageDialog aMessageDialog = new org.jacorb.poa.gui.beans.MessageDialog(new java.awt.Frame JavaDoc());
234         aMessageDialog.setModal(true);
235         try {
236             Class JavaDoc aCloserClass = Class.forName("com.ibm.uvm.abt.edit.WindowCloser");
237             Class JavaDoc parmTypes[] = { java.awt.Window JavaDoc.class };
238             Object JavaDoc parms[] = { aMessageDialog };
239             java.lang.reflect.Constructor JavaDoc aCtor = aCloserClass.getConstructor(parmTypes);
240             aCtor.newInstance(parms);
241         } catch (java.lang.Throwable JavaDoc exc) {};
242         aMessageDialog.setVisible(true);
243     } catch (Throwable JavaDoc exception) {
244         System.err.println("Exception occurred in main() of java.awt.Dialog");
245         exception.printStackTrace(System.out);
246     }
247 }
248 /**
249  * Method to handle events for the WindowListener interface.
250  * @param e java.awt.event.WindowEvent
251  */

252 /* WARNING: THIS METHOD WILL BE REGENERATED. */
253 public void windowActivated(java.awt.event.WindowEvent JavaDoc e) {
254     // user code begin {1}
255
// user code end
256
// user code begin {2}
257
// user code end
258
}
259 /**
260  * Method to handle events for the WindowListener interface.
261  * @param e java.awt.event.WindowEvent
262  */

263 /* WARNING: THIS METHOD WILL BE REGENERATED. */
264 public void windowClosed(java.awt.event.WindowEvent JavaDoc e) {
265     // user code begin {1}
266
// user code end
267
// user code begin {2}
268
// user code end
269
}
270 /**
271  * Method to handle events for the WindowListener interface.
272  * @param e java.awt.event.WindowEvent
273  */

274 /* WARNING: THIS METHOD WILL BE REGENERATED. */
275 public void windowClosing(java.awt.event.WindowEvent JavaDoc e) {
276     // user code begin {1}
277
// user code end
278
if ((e.getSource() == this) ) {
279         connEtoC1(e);
280     }
281     // user code begin {2}
282
// user code end
283
}
284 /**
285  * Method to handle events for the WindowListener interface.
286  * @param e java.awt.event.WindowEvent
287  */

288 /* WARNING: THIS METHOD WILL BE REGENERATED. */
289 public void windowDeactivated(java.awt.event.WindowEvent JavaDoc e) {
290     // user code begin {1}
291
// user code end
292
// user code begin {2}
293
// user code end
294
}
295 /**
296  * Method to handle events for the WindowListener interface.
297  * @param e java.awt.event.WindowEvent
298  */

299 /* WARNING: THIS METHOD WILL BE REGENERATED. */
300 public void windowDeiconified(java.awt.event.WindowEvent JavaDoc e) {
301     // user code begin {1}
302
// user code end
303
// user code begin {2}
304
// user code end
305
}
306 /**
307  * Method to handle events for the WindowListener interface.
308  * @param e java.awt.event.WindowEvent
309  */

310 /* WARNING: THIS METHOD WILL BE REGENERATED. */
311 public void windowIconified(java.awt.event.WindowEvent JavaDoc e) {
312     // user code begin {1}
313
// user code end
314
// user code begin {2}
315
// user code end
316
}
317 /**
318  * Method to handle events for the WindowListener interface.
319  * @param e java.awt.event.WindowEvent
320  */

321 /* WARNING: THIS METHOD WILL BE REGENERATED. */
322 public void windowOpened(java.awt.event.WindowEvent JavaDoc e) {
323     // user code begin {1}
324
// user code end
325
// user code begin {2}
326
// user code end
327
}
328
329 }
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
Popular Tags