SymbolTestpublic 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 |
Methods Summary |
---|
public void | actionPerformed(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 void | init()
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=0x0370"));
| public void | itemStateChanged(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 void | main(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());
|
|