Here you can find the source of getMethodGetFontMetrics()
private static Method getMethodGetFontMetrics()
//package com.java2s; import java.awt.Graphics; import java.lang.reflect.Method; import javax.swing.JComponent; public class Main { private static final String SWING_UTILITIES2_NAME = "sun.swing.SwingUtilities2"; private static Method getMethodGetFontMetrics() { try {//from w w w . java 2s . c om Class clazz = Class.forName(SWING_UTILITIES2_NAME); return clazz.getMethod("getFontMetrics", new Class[] { JComponent.class, Graphics.class }); } catch (ClassNotFoundException e) { // returns null } catch (SecurityException e) { // returns null } catch (NoSuchMethodException e) { // returns null } return null; } }