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.swingui;
14:
15: import java.awt.Color;
16: import java.awt.Container;
17: import java.awt.CardLayout;
18:
19: import javax.swing.JFrame;
20:
21: import java.awt.event.WindowAdapter;
22: import java.awt.event.WindowEvent;
23:
24: import com.ibm.richtext.styledtext.MConstText;
25:
26: import com.ibm.richtext.textpanel.JTextPanel;
27: import com.ibm.richtext.textpanel.TextPanelSettings;
28:
29: /**
30: * MessageDialog is a simple Frame which displays a styled
31: * text message in a TextPanel.
32: * The text in the message is not selectable or editable.
33: * @see MConstText
34: * @see JTextPanel
35: */
36: public final class JMessageDialog extends JFrame {
37:
38: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
39:
40: /**
41: * Create a new MessageDialog.
42: * @param title the dialog's title
43: * @param message the text which will appear in the dialog
44: */
45: public JMessageDialog(String title, MConstText message) {
46: super (title);
47:
48: Container content = getContentPane();
49: content.setLayout(new CardLayout());
50: TextPanelSettings settings = JTextPanel.getDefaultSettings();
51: settings.setScrollable(false);
52: settings.setSelectable(false);
53: JTextPanel panel = new JTextPanel(settings, message, null);
54:
55: panel.setBackground(Color.black);
56: content.add("Center", panel);
57:
58: addWindowListener(new WindowAdapter() {
59: public void windowClosing(WindowEvent e) {
60: setVisible(false);
61: dispose();
62: }
63: });
64:
65: setSize(450, 320);
66: }
67: }
|