Text width/height (original) (raw)
How do I find out the size of rendered text?
Specifically, I want to draw text in the middle of a JPanel. Something like this:
public void paint (Graphics g)
{
int x = getWidth()/2 - getTextWidth ("String")/2;
int y = getHeight()/2 - getTextHeight ("String")/2;
g.drawString ("String", x, y);
}
Except, of course, that getTextWidth and getTextHeight don't exist, so what do I need to use?
I'm following this tutorial on the netbeans website for a simpleEE7App. I followed the instructions precisely but got an exception need help. :/…
anyone here?
It seems that you can override a concrete method and make it abstract. I actually came across some code that did this, so I had to check how it…