Here you can find the source of getFontMetrics(Font font)
Parameter | Description |
---|---|
font | The font for which font metrics is to be obtained. |
public static FontMetrics getFontMetrics(Font font)
//package com.java2s; import java.awt.Font; import java.awt.FontMetrics; import javax.swing.JPanel; public class Main { /**// w w w. j ava 2 s.c o m * A JPanel from which we can gain font metrics. */ private static final JPanel DUMMY_PANEL = new JPanel(); /** * Gets the font metrics for the specified font. * * @param font * The font for which font metrics is to be obtained. * @return the FontMetrics */ public static FontMetrics getFontMetrics(Font font) { // return Toolkit.getDefaultToolkit().getFontMetrics(font); return DUMMY_PANEL.getFontMetrics(font); } }