Java - AWT/Swing

FontMetrics

java.awt.FontMetrics
java.awt.Graphics
This class comes up with information to a font.
The example hands out the total width of a string:


public void paint(Graphics g) {
   String str = "Test";
   FontMetrics fm = g.getFontMetrics(g.getFont());
   System.out.println("width of 'Test': "+fm.stringWidth(str));
}

Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007