KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > mobilitools > util > gui > AlertWindow


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

26
27
28 package org.objectweb.mobilitools.util.gui;
29
30
31 import java.awt.*;
32 import java.awt.event.*;
33
34
35 public class AlertWindow extends Dialog implements ActionListener
36 {
37     Button OKbtn;
38
39
40     public AlertWindow(Frame frame, String JavaDoc title, String JavaDoc text, String JavaDoc button)
41     {
42         super(frame, title, true);
43
44         setLayout(new BorderLayout());
45         TextArea textZone = new TextArea(text, 5, 30);
46         textZone.setEditable(false);
47         add("Center", textZone);
48         add("South", OKbtn = new Button(button));
49         OKbtn.addActionListener(this);
50         addWindowListener(new OnWindowClosing());
51         pack();
52         show();
53     }
54
55
56     public AlertWindow(boolean modal, Frame frame, String JavaDoc title, String JavaDoc text, String JavaDoc button)
57     {
58         super(frame, title, modal);
59
60         setLayout(new BorderLayout());
61         TextArea textZone = new TextArea(text, 5, 30);
62         textZone.setEditable(false);
63         add("Center", textZone);
64         add("South", OKbtn = new Button(button));
65         OKbtn.addActionListener(this);
66         addWindowListener(new OnWindowClosing());
67         pack();
68         show();
69     }
70
71
72     ////////////////////////////////////////////////
73
// Implementation of interface ActionListener //
74
////////////////////////////////////////////////
75

76
77     public void actionPerformed(ActionEvent evt)
78     {
79         dispose();
80     }
81
82
83     ///////////////////////////////////////
84
// inner WindowAdapter-derived class //
85
///////////////////////////////////////
86

87
88     class OnWindowClosing extends WindowAdapter
89     {
90         public void windowClosing(WindowEvent e)
91         {
92             AlertWindow.this.dispose();
93         }
94     }
95 }
96
Popular Tags