FileDocCategorySizeDatePackage
SymbolTest.javaAPI DocExample4585Wed Apr 19 11:22:14 BST 2000None

SymbolTest

public class SymbolTest extends Applet implements ActionListener, ItemListener

Fields Summary
SymbolCanvas
symbols
TextField
baseText
static final int
SYMBOL_BASE
static final int
DINGBAT_BASE
static final int
GREEK_BASE
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

        try {
            int newBase = Integer.valueOf(e.getActionCommand(), 16).intValue();
            symbols.setBase(newBase);
        } catch (NumberFormatException nfe) {
            Toolkit.getDefaultToolkit().beep();
            baseText.select(0, Integer.MAX_VALUE);
        }
    
public voidinit()


       
	setLayout(new BorderLayout());

        Panel panel = new Panel();

        panel.add(new Label("Font:"));
        Choice fontList = new Choice();
        String[] fontNames = getToolkit().getFontList();
        for (int i = 0; i < fontNames.length; i++) {
            fontList.addItem(fontNames[i]);
        }
        fontList.addItemListener(this);
        panel.add(fontList);
        Font defaultFont = new Font(fontNames[0], Font.PLAIN, 16);

        panel.add(new Label("Unicode base:"));
        baseText = new TextField(Integer.toHexString(DINGBAT_BASE), 4);
        baseText.setFont(new Font("Monospaced", Font.PLAIN, 12));
        baseText.addActionListener(this);
        panel.add(baseText);
        add("North", panel);

        ScrollPane sp = new ScrollPane();
        symbols = new SymbolCanvas(defaultFont, DINGBAT_BASE);
        sp.add(symbols);
        add("Center", sp);

        add("South", new Label("Symbols=0x2200, Dingbats=0x2700, Greek=0x3300"));
    
public voiditemStateChanged(java.awt.event.ItemEvent e)

        if (e.getStateChange() == ItemEvent.SELECTED) {
            String fontName = (String)e.getItem();
            symbols.setFont(new Font(fontName, Font.PLAIN, 16));
        }
    
public static voidmain(java.lang.String[] args)

	Frame f = new Frame("SymbolTest");
	SymbolTest symbolTest = new SymbolTest();

	symbolTest.init();
	symbolTest.start();

	f.add("Center", symbolTest);
	f.pack();
	f.setSize(400, 500);
	f.show();

        f.addWindowListener(new MyAdapter());