Example #1
0
  protected int getFullTextHeight(GGraphics2D g2, String text) {
    // make sure layout won't be null ("" makes it null).

    GTextLayout layout = getLayout(g2, text, getLabelFont());

    return (int) (layout.getAscent() + layout.getDescent());
  }
Example #2
0
  protected int getTextHeight(GGraphics2D g2, String text) {
    // make sure layout won't be null ("" makes it null).

    GTextLayout layout =
        g2.getFontRenderContext().getTextLayout("".equals(text) ? "A" : text, getLabelFont());

    return (int) (layout.getBounds().getHeight());
  }