public StringWidth() {
Font plain = new Font("Dialog", Font.PLAIN, 10);
Font bold = new Font("Dialog", Font.BOLD, 10);
Properties props = new Properties(); int x, y;
// we must have visible Frame context for PrintDialog in Solaris
setSize(400, 300);
setVisible(true);
// now right justify on the printed page int center = size.width/2;
y = 150;
x = center - plainFm.stringWidth(test);
pg.setFont(plain);
pg.drawString(test, x-1, y);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.