Maybe the problem is the grabFocus() method. In general
you should be using requestFocusInWindow() to request focus on a component.
However, you should NOT be using a FocusListener for this.
Instead you should be using an InputVerifier. It will handle all this code for you. Read the API for a working example.