KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > console > lib > gui > GuiAlert


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 2004 France Telecom R&D
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * CLIF $Name: $
20 *
21 * Contact: clif@objectweb.org
22 */

23
24 package org.objectweb.clif.console.lib.gui;
25
26 import javax.swing.JDialog JavaDoc;
27 import javax.swing.JButton JavaDoc;
28 import javax.swing.JFrame JavaDoc;
29 import javax.swing.JPanel JavaDoc;
30 import javax.swing.JTextArea JavaDoc;
31 import java.awt.event.ActionListener JavaDoc;
32 import java.awt.event.ActionEvent JavaDoc;
33 import java.awt.event.WindowAdapter JavaDoc;
34 import java.awt.event.WindowEvent JavaDoc;
35 import java.awt.Container JavaDoc;
36 import java.awt.BorderLayout JavaDoc;
37
38
39 /**
40  *
41  * @author Bruno Dillenseger
42  */

43 public class GuiAlert extends JDialog JavaDoc implements ActionListener JavaDoc
44 {
45     protected JButton JavaDoc okBtn;
46
47
48     GuiAlert(JFrame JavaDoc frame, String JavaDoc title, String JavaDoc message)
49     {
50         super(frame, title, true);
51         Container JavaDoc pane = getContentPane();
52         pane.setLayout(new BorderLayout JavaDoc());
53         if (message != null)
54         {
55             pane.add(BorderLayout.CENTER, new JTextArea JavaDoc(message, 5, 40));
56         }
57         JPanel JavaDoc buttonPnl = new JPanel JavaDoc();
58         buttonPnl.add(okBtn = new JButton JavaDoc("OK"));
59         okBtn.addActionListener(this);
60         pane.add(BorderLayout.SOUTH, buttonPnl);
61         addWindowListener(new WindowCloser());
62     }
63
64
65     public void alert()
66     {
67         pack();
68         show();
69     }
70
71
72     public void actionPerformed(ActionEvent JavaDoc e)
73     {
74         this.dispose();
75     }
76
77
78     class WindowCloser extends WindowAdapter JavaDoc
79     {
80         public void windowClosing(WindowEvent JavaDoc e)
81         {
82             GuiAlert.this.dispose();
83         }
84     }
85 }
86
Popular Tags