Thank you for your replies. I have managed to make a lot of headway but have stumbled onto a small problem.
I am trying to display text on the screen and put say, a rectangle around it. The problem is I do not know how to get the bounding box of a string of text without using the graphics component. I would like to generate the bounding box in the objects constructor instead of in the paint method.
For example:
public myclass(String text, int x, int y)
{
Rectangle bounds = new Rectangle();
int width, height;
//code here to get the bounding of text
width = text.getWidthInPixels();
height = text.getHeightInPixels();
bounds.x = x;
bounds.y = y; ....etc
}
Anyways, it seems the only way that I know of doing is in the paint type methods of the swing components. Is there another way?
Thanks