P
Peter Ahrens
I will draw a rectangle with a string inside. Now I need the bounds of a
given string to get size of the rectangle. How can I get the bounds of a
String? I have found getStringBounds of Font. But the function needs a
FontRenderContext? Where can I get the FontRenderContext?
My function at the moment:
public void Draw(Graphics g)
{
g.setColor(Color.BLUE);
// g.getFont().getStringBounds(text, )
// g.drawString(text);
g.drawRect(10, 10, 20, 30);
}
Peter
given string to get size of the rectangle. How can I get the bounds of a
String? I have found getStringBounds of Font. But the function needs a
FontRenderContext? Where can I get the FontRenderContext?
My function at the moment:
public void Draw(Graphics g)
{
g.setColor(Color.BLUE);
// g.getFont().getStringBounds(text, )
// g.drawString(text);
g.drawRect(10, 10, 20, 30);
}
Peter