get Font Height - Java 2D Graphics

Java examples for 2D Graphics:Font

Description

get Font Height

Demo Code


//package com.java2s;

import java.awt.Font;
import java.awt.FontMetrics;

import java.awt.Graphics;

public class Main {
    public static int getFontHeight(Graphics offLineBuffer, Font font) {
        offLineBuffer.setFont(font);/* ww  w  .  j  a va2 s .c  o  m*/
        FontMetrics fontmetrics = offLineBuffer.getFontMetrics();
        return fontmetrics.getHeight();
    }
}

Related Tutorials