Java Code Examples for java.awt.Frame#addNotify()

The following examples show how to use java.awt.Frame#addNotify() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PDFGraphics.java    From jpexs-decompiler with GNU General Public License v3.0 votes vote down vote up
/**
   * Returns the FontMetrics for a font.
   * <p>This doesn't work correctly. Perhaps having some way of mapping
   * the base 14 fonts to our own FontMetrics implementation?
   * @param font The java.awt.Font to return the metrics for
   * @return FontMetrics for a font
   */
  public FontMetrics getFontMetrics(Font font) {
    Frame dummy = new Frame();
    dummy.addNotify();
    Image image = dummy.createImage(100, 100);
    if (image == null) {
      System.err.println("getFontMetrics: image is null");
    }
    Graphics graphics = image.getGraphics();
    return graphics.getFontMetrics(font);

  }