Here you can find the source of getLineHeight(Component c, int defaultHeight)
Parameter | Description |
---|---|
c | the component |
defaultHeight | the default height if the font on the specified component is null |
public static int getLineHeight(Component c, int defaultHeight)
//package com.java2s; import java.awt.*; public class Main { /**/*from w w w . ja v a2 s.c om*/ * Gets the line height for the font for the component * * @param c the component * @param defaultHeight the default height if the font on the specified component is null * @return the line height for the font for the component (or the passed in the default value if the font on the * specified component is null) */ public static int getLineHeight(Component c, int defaultHeight) { Font f = c == null ? null : c.getFont(); if (f == null) { return defaultHeight; } FontMetrics fm = c.getFontMetrics(f); float h = fm.getHeight(); h += fm.getDescent(); return (int) h; } }