View RSS Feed

Java AWT

Java Abstract Window Toolkit (AWT)

  1. Measuring Text

    by , 03-07-2012 at 05:46 PM
    For measuring text properly you shall be learning certain important methods and also few mistakes shall be avoided. Font metrics are considered as the measure of the text which has been rendered by the font object like, height of line in font. By using FontMetrics instance, you can measure text easily and this is one of the most common way to do so. E.g,
    Java Code:
    // get metrics from the graphics
    FontMetrics metrics = graphics.getFontMetrics(font);
    // get the height of a line