Java FontMetrics getPrefSize(FontMetrics fm, String keyTip)

Here you can find the source of getPrefSize(FontMetrics fm, String keyTip)

Description

get Pref Size

License

Open Source License

Declaration

public static Dimension getPrefSize(FontMetrics fm, String keyTip) 

Method Source Code

//package com.java2s;
import java.awt.*;

public class Main {
    private static int INSETS = 3;

    public static Dimension getPrefSize(FontMetrics fm, String keyTip) {
        int prefWidth = fm.stringWidth(keyTip) + 2 * INSETS + 1;
        int prefHeight = fm.getHeight() + INSETS - 1;
        return new Dimension(prefWidth, prefHeight);
    }/*from w  w  w.  j  ava2 s  . co m*/
}

Related

  1. getLongestStringWidth(FontMetrics fm, String[] theStrings)
  2. getMaxFittingFontSize(Graphics g, Font font, String string, Dimension size)
  3. getMaxFontHeight(final java.awt.Font font)
  4. getMonospacedFontNames()
  5. getMonospacedFontsFamillyName()
  6. getStringForMaxWidth(FontMetrics fm, String s, int maxWidth)
  7. getStringImage(Font font, String... strs)
  8. getStringLengthInPixels(String s, Graphics g)
  9. getStringRect(Font f, String s)