Java Swing Font Metrics getMethodGetFontMetrics()

Here you can find the source of getMethodGetFontMetrics()

Description

get Method Get Font Metrics

License

Open Source License

Declaration

private static Method getMethodGetFontMetrics() 

Method Source Code


//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;
    }
}

Related

  1. getFontMetrics(JComponent c, Graphics g)
  2. getFontMetrics(JComponent c, Graphics g, Font f)
  3. getFontMetrics(JComponent c, Graphics g, Font font)
  4. getFRC(JComponent c, FontMetrics fm)
  5. getImage(String text, boolean clockwise, Font font, FontMetrics fm, Color bg, Color fontColor)
  6. getTabbedTextOffset(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset)
  7. getTabbedTextWidth(Segment s, FontMetrics metrics, int x, TabExpander e, int startOffset)
  8. getTextBounds(FontMetrics fm, String s)
  9. getWidthOfText(FontMetrics fontMetrics, String text)