I have the following line i my code.
page.drawString("Distance: " + dist + " pixels", 50., 50);
How can I plase this text so it always is in the center of the applet.
Printable View
I have the following line i my code.
page.drawString("Distance: " + dist + " pixels", 50., 50);
How can I plase this text so it always is in the center of the applet.
I had an example somewhere, but I can't find it right now. I do know that int the paint method, you use a FontMetrics object to find the String's width. Then you use the getBounds method of the applet to get the width and height. You can divide the 2 in half to find the center.
If I find the actual code, I'll post it. It's not tough.
:)