Java Reference
In-Depth Information
Figure 7−1. Some Unicode characters and their encodings
Example 7-1 lists code used to create the displays of Figure 7-1. Because Unicode
characters are integrated so fundamentally into the Java language, this Uni-
codeDisplay program does not perform any sophisticated internationalization
techniques to display Unicode glyphs. Thus, you'll find that Example 7-1 is more
of a Swing GUI example rather than an internationalization example. If you
haven't read Chapter 10 yet, you may not understand all the code in this example.
Example 7−1: UnicodeDisplay.java
package com.davidflanagan.examples.i18n;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* This program displays Unicode glyphs using user-specified fonts
* and font styles.
**/
public class UnicodeDisplay extends JFrame implements ActionListener {
int page = 0;
UnicodePanel p;
JScrollBar b;
String fontfamily = "Serif";
int fontstyle = Font.PLAIN;
/**
* This constructor creates the frame, menubar, and scrollbar
* that work along with the UnicodePanel class, defined below
**/
public UnicodeDisplay(String name) {
super(name);
p = new UnicodePanel();
// Create the panel
p.setBase((char)(page * 0x100));
// Initialize it
getContentPane().add(p, "Center");
// Center it
Search WWH ::




Custom Search