]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/richtext/swingui/JMessageDialog.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / richtext / swingui / JMessageDialog.java
1 /*\r
2  * (C) Copyright IBM Corp. 1998-2007.  All Rights Reserved.\r
3  *\r
4  * The program is provided "as is" without any warranty express or\r
5  * implied, including the warranty of non-infringement and the implied\r
6  * warranties of merchantibility and fitness for a particular purpose.\r
7  * IBM will not be liable for any damages suffered by you as a result\r
8  * of using the Program. In no event will IBM be liable for any\r
9  * special, indirect or consequential damages or lost profits even if\r
10  * IBM has been advised of the possibility of their occurrence. IBM\r
11  * will not be liable for any third party claims against you.\r
12  */\r
13 package com.ibm.richtext.swingui;\r
14 \r
15 import java.awt.Color;\r
16 import java.awt.Container;\r
17 import java.awt.CardLayout;\r
18 \r
19 import javax.swing.JFrame;\r
20 \r
21 import java.awt.event.WindowAdapter;\r
22 import java.awt.event.WindowEvent;\r
23 \r
24 import com.ibm.richtext.styledtext.MConstText;\r
25 \r
26 import com.ibm.richtext.textpanel.JTextPanel;\r
27 import com.ibm.richtext.textpanel.TextPanelSettings;\r
28 \r
29 /**\r
30  * MessageDialog is a simple Frame which displays a styled\r
31  * text message in a TextPanel.\r
32  * The text in the message is not selectable or editable.\r
33  * @see MConstText\r
34  * @see JTextPanel\r
35  */\r
36 public final class JMessageDialog extends JFrame {\r
37 \r
38     /**\r
39      * For serialization\r
40      */\r
41     private static final long serialVersionUID = 5012952859760456427L;\r
42 \r
43     //static final String COPYRIGHT =\r
44     //            "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";\r
45     /**\r
46     * Create a new MessageDialog.\r
47     * @param title the dialog's title\r
48     * @param message the text which will appear in the dialog\r
49     */\r
50     public JMessageDialog(String title, MConstText message)\r
51     {\r
52         super(title);\r
53 \r
54         Container content = getContentPane();\r
55         content.setLayout(new CardLayout());\r
56         TextPanelSettings settings = JTextPanel.getDefaultSettings();\r
57         settings.setScrollable(false);\r
58         settings.setSelectable(false);\r
59         JTextPanel panel = new JTextPanel(settings, message, null);\r
60 \r
61         panel.setBackground(Color.black);\r
62         content.add("Center", panel);\r
63 \r
64         addWindowListener(new WindowAdapter() {\r
65             public void windowClosing(WindowEvent e) {\r
66                 setVisible(false);\r
67                 dispose();\r
68             }\r
69         });\r
70 \r
71         setSize(450,320);\r
72     }\r
73 }\r