public class UnicodeJFrame extends JFrame
1: // Fig. F.3: UnicodeJFrame.java
2: // Demonstrating how to use Unicode in Java programs.
3: import java.awt.GridLayout;
4: import javax.swing.JFrame;
5: import javax.swing.JLabel;
6:
7: public class UnicodeJFrame extends JFrame
8: {
9: // constructor creates JLabels to display Unicode
10: public UnicodeJFrame()
11: {
12: super( "Demonstrating Unicode" );
13:
14: setLayout( new GridLayout( 8, 1 ) ); // set frame layout
15:
16: // create JLabels using Unicode
17: JLabel englishJLabel = new JLabel( "\u0057\u0065\u006C\u0063" +
18: "\u006F\u006D\u0065\u0020\u0074\u006F\u0020Unicode\u0021" );
19: englishJLabel.setToolTipText( "This is English" );
20: add( englishJLabel );
21:
22: JLabel chineseJLabel = new JLabel( "\u6B22\u8FCE\u4F7F\u7528" +
23: "\u0020\u0020Unicode\u0021" );
24: chineseJLabel.setToolTipText( "This is Traditional Chinese" );
25: add( chineseJLabel );
26:
27: JLabel cyrillicJLabel = new JLabel( "\u0414\u043E\u0431\u0440" +
28: "\u043E\u0020\u043F\u043E\u0436\u0430\u043B\u043E\u0432" +
29: "\u0430\u0422\u044A\u0020\u0432\u0020Unicode\u0021" );
30: cyrillicJLabel.setToolTipText( "This is Russian" );
31: add( cyrillicJLabel );
32:
33: JLabel frenchJLabel = new JLabel( "\u0042\u0069\u0065\u006E\u0076" +
34: "\u0065\u006E\u0075\u0065\u0020\u0061\u0075\u0020Unicode\u0021");
35: frenchJLabel.setToolTipText( "This is French" );
36: add( frenchJLabel );
37:
38: JLabel germanJLabel = new JLabel( "\u0057\u0069\u006C\u006B\u006F" +
39: "\u006D\u006D\u0065\u006E\u0020\u007A\u0075\u0020Unicode\u0021");
40: germanJLabel.setToolTipText( "This is German" );
41: add( germanJLabel );
42:
43: JLabel japaneseJLabel = new JLabel( "Unicode\u3078\u3087\u3045" +
44: "\u3053\u305D\u0021" );
45: japaneseJLabel.setToolTipText( "This is Japanese" );
46: add( japaneseJLabel );
47:
48: JLabel portugueseJLabel = new JLabel( "\u0053\u00E9\u006A\u0061" +
49: "\u0020\u0042\u0065\u006D\u0076\u0069\u006E\u0064\u006F\u0020" +
50: "Unicode\u0021" );
51: portugueseJLabel.setToolTipText( "This is Portuguese" );
52: add( portugueseJLabel );
53:
54: JLabel spanishJLabel = new JLabel( "\u0042\u0069\u0065\u006E" +
55: "\u0076\u0065\u006E\u0069\u0064\u0061\u0020\u0061\u0020" +
56: "Unicode\u0021" );
57: spanishJLabel.setToolTipText( "This is Spanish" );
58: add( spanishJLabel );
59: } // end UnicodeJFrame constructor
60: } // end class UnicodeJFrame
61:
62:
63:
64:
65: /**************************************************************************
66: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
67: * Pearson Education, Inc. All Rights Reserved. *
68: * *
69: * DISCLAIMER: The authors and publisher of this book have used their *
70: * best efforts in preparing the book. These efforts include the *
71: * development, research, and testing of the theories and programs *
72: * to determine their effectiveness. The authors and publisher make *
73: * no warranty of any kind, expressed or implied, with regard to these *
74: * programs or to the documentation contained in these books. The authors *
75: * and publisher shall not be liable in any event for incidental or *
76: * consequential damages in connection with, or arising out of, the *
77: * furnishing, performance, or use of these programs. *
78: *************************************************************************/
79: