setFont(new Font("Monospaced", Font.BOLD, 18)); fm = Toolkit.getDefaultToolkit().getFontMetrics(getFont()); fontHeight = fm.getHeight(); cs.addCharacterListener(this);
tmpChar[0] = (char) ce.character; repaint();
if (tmpChar[0] == 0) return; Dimension d = getSize(); int charWidth = fm.charWidth((int) tmpChar[0]); gc.clearRect(0, 0, d.width, d.height); gc.drawChars(tmpChar, 0, 1, (d.width - charWidth) / 2, fontHeight);
return new Dimension(fm.getMaxAscent() + 10, fm.getMaxAdvance() + 10);
cs.addCharacterListener(this);