01: /*
02: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
03: *
04: * The program is provided "as is" without any warranty express or
05: * implied, including the warranty of non-infringement and the implied
06: * warranties of merchantibility and fitness for a particular purpose.
07: * IBM will not be liable for any damages suffered by you as a result
08: * of using the Program. In no event will IBM be liable for any
09: * special, indirect or consequential damages or lost profits even if
10: * IBM has been advised of the possibility of their occurrence. IBM
11: * will not be liable for any third party claims against you.
12: */
13: package com.ibm.richtext.awtui;
14:
15: import java.awt.Color;
16: import java.awt.Frame;
17: import java.awt.CardLayout;
18:
19: import java.awt.event.WindowAdapter;
20: import java.awt.event.WindowEvent;
21:
22: import com.ibm.richtext.styledtext.MConstText;
23:
24: import com.ibm.richtext.textpanel.TextPanel;
25: import com.ibm.richtext.textpanel.TextPanelSettings;
26:
27: /**
28: * MessageDialog is a simple Frame which displays a styled
29: * text message in a TextPanel.
30: * The text in the message is not selectable or editable.
31: * @see MConstText
32: * @see TextPanel
33: */
34: public final class MessageDialog extends Frame {
35:
36: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
37:
38: /**
39: * Create a new MessageDialog.
40: * @param title the dialog's title
41: * @param message the text which will appear in the dialog
42: */
43: public MessageDialog(String title, MConstText message) {
44: super (title);
45:
46: setLayout(new CardLayout());
47: TextPanelSettings settings = TextPanel.getDefaultSettings();
48: settings.setScrollable(false);
49: settings.setSelectable(false);
50: TextPanel panel = new TextPanel(settings, message, null);
51:
52: panel.setBackground(Color.black);
53: add("Center", panel);
54:
55: addWindowListener(new WindowAdapter() {
56: public void windowClosing(WindowEvent e) {
57: setVisible(false);
58: dispose();
59: }
60: });
61:
62: setSize(450, 320);
63: }
64: }
|