console cursor

hey guys :wink:

here’s my next problem:

I implemented a console into my game, it’s fairly simple, but I have one problem: I wanted a blinking cursor in the input line, so I just used
g.drawString("|", 13+curpos6, 195);
which about fit with the position
6. but after about 15 chars, the | advances noticeably faster than the text, with 5.9 it’s slower, and it’s a workaround-solution anyways.

is there any better solution to font-dependantly get the position where the | should be located?

I took a look at the Font class but it’s rather confusing and google didn’t help me on that one either (“font” and “cursor” aren’t excactly precise keywords)
http://www.mugenguild.com/forumx/Smileys/mfg/dead.gif

Graphics.getFontMetrics().stringWidth(String)

perfect. thanks.

(damn, I did look at the FontMetrics class but didn’t see the stringWidth method X( )