01: // MessagePopup.java
02: // $Id: MessagePopup.java,v 1.8 2000/08/16 21:37:56 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1997.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.tools.widgets;
07:
08: import java.awt.BorderLayout;
09: import java.awt.Button;
10: import java.awt.Color;
11: import java.awt.Component;
12: import java.awt.Container;
13: import java.awt.FlowLayout;
14: import java.awt.Frame;
15: import java.awt.Label;
16: import java.awt.Panel;
17: import java.awt.Window;
18:
19: import java.awt.event.ActionEvent;
20: import java.awt.event.ActionListener;
21:
22: /**
23: * A very simple popup displaying a message.
24: * @author Benoit Mahe <bmahe@sophia.inria.fr>
25: */
26:
27: public class MessagePopup implements ActionListener {
28:
29: Frame frame = null;
30: Label msg = null;
31: Button okB = null;
32:
33: public void actionPerformed(ActionEvent evt) {
34: if (evt.getSource() == okB)
35: frame.dispose();
36: }
37:
38: /**
39: * show the popup.
40: */
41: public void show() {
42: frame.show();
43: }
44:
45: /**
46: * build a Message popup.
47: * @param message, The message to display
48: */
49: public MessagePopup(String message) {
50: this ("", message);
51: }
52:
53: /**
54: * build a Message popup.
55: * @param title, the title.
56: * @param message, The message to display
57: */
58: public MessagePopup(String title, String message) {
59: msg = new Label(message);
60: BorderPanel pmsg = new BorderPanel(BorderPanel.IN, 2);
61: pmsg.setLayout(new FlowLayout());
62: pmsg.add(msg);
63: okB = new Button("Ok");
64: okB.addActionListener(this );
65: frame = new Frame(title);
66: frame.setBackground(Color.lightGray);
67: frame.setLayout(new BorderLayout());
68: frame.add(pmsg, "North");
69: Panel p = new Panel();
70: p.add(okB);
71: frame.add(p, "South");
72: frame.pack();
73: }
74:
75: }
|