Attempts to set the focus to this control and activate the form that contains this control, and returns a boolean value indicating whether the attempt succeeded.
public final boolean focus()
Returns true if the focus is successfully set to this control; otherwise, returns false.
Use the canFocus method to determine whether a control can receive the focus. Using the setActiveControl method is a more robust way than using the focus method to set the active control on a form because it does not activate inactive forms.