Page 496 - Introduction to Programming with Java: A Problem Solving Approach
P. 496
462 Chapter 11 Type Details and Alternate Coding Mechanisms
/**********************************************************
*
UnicodeDisplay.java
Dean & Dean
This prints unicode characters.
**********************************************************/
*
*
*
import javax.swing.*;
import java.awt.Font;
public class UnicodeDisplay
{
}
// end UnicodeDisplay
public static void main(String[] args)
{
}
// end main
int[] codes = {'\u0391',
'\u0410',
'\u2200',
'\u2500',
'\u2700'};
String[] descriptions = {"Greek",
"Cyrillic (Russian)",
"mathematical operators",
"box drawing",
Apago"diPngDbFats"E};nhancer JFrame window = new JFrame("Some Unicode Characters");
JTextArea area = new JTextArea();
Font font = area.getFont();
window.setSize(600,285);
// pixel width, height
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.add(area);
area.setLineWrap(true);
area.append("Font type, style, and size: " +
font.getFontName() + ", " + font.getSize() + "\n");
for (int i=0; i<codes.length; i++)
{
}
area.append("0x" + Integer.toString(codes[i], 16) +
" " + descriptions[i] + ":\n");
for (int j=0; j<=72; j++)
{
}
area.append((char) (codes[i] + j) + " ");
area.append("\n");
window.setVisible(true);
Figure 11.11 Program that uses GUI to display a sampling of Unicode characters