Java FontMetrics maxSize(Component component, String maxString)

Here you can find the source of maxSize(Component component, String maxString)

Description

max Size

License

Apache License

Declaration

public static Dimension maxSize(Component component, String maxString) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.*;

public class Main {
    public static Dimension maxSize(Component component, String maxString) {
        FontMetrics fontMetrics = component.getFontMetrics(component.getFont());
        return new Dimension(Math.max(fontMetrics.stringWidth(maxString), component.getPreferredSize().width),
                fontMetrics.getHeight());
    }/*from   www.  j a  va 2s  .c  o m*/
}

Related

  1. getStringLengthInPixels(String s, Graphics g)
  2. getStringRect(Font f, String s)
  3. getTextCenterShear(final FontMetrics fm, final String text)
  4. getTextCenterShearX(final FontMetrics fm, final String text)
  5. limitWithEllipsis(String str, Font font, int maxWidth, Component c)
  6. maxStringPixelWidth(String[] strings, FontMetrics fm)
  7. paintString(String s, Graphics2D g2, Rectangle2D rect, float horizontal, float vertical)
  8. render(Graphics2D graphics, String str, Rectangle2D box, double xalign, double yalign)
  9. setComponentSize(Component component, int rows, int columns)