Is there some way to set focus back to a Text Field because just using focus() doesnt seem to work?

I read posts on various forums but all have focusing problem when the page first loads up. In my case however, when the page first loads, the focus is fine. However, it messes up after I do some processing. I tried using focus() after this processing but that doesnt seem to work.