Here you can find the source of getFontHeight(JComponent component)
public static int getFontHeight(JComponent component)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; public class Main { public static int getFontHeight(JComponent component) { return getFontHeight(component, component.getFont()); }//from w w w . ja v a 2 s .c o m public static int getFontHeight(JComponent component, Font font) { return component == null ? -1 : component.getFontMetrics(font).getHeight(); } }