I can't answer your question directly, but if i was writing that code I would simply use .length() to get the string's length and then calculate the frame from there. You may also want to take a look...