"I am drawing a string [via g.drawString()] on a JComponent and I want to enlarge the component if needed, so that it doesn't clip the string. I can't figure out how to find the size of the string that will be drawn, to resize the component. Any ideas?"
You can use the following code segment to obtain the width of the String drawn. someFont variable is the font used by the component and someString is the string drawn:
FontMetrics fm = someComponent.getFontMetrics(someFont); int width = fm.stringWidth(someString);