U can add the focusLostListener method to the text field u want to validate.
This focus lost will be called when the focus has been lost from the
textfiled u want to validate. This can be like when u pressed tab from the
textfield or u press on some other component in the dialog or frame this
method will be called.
If u want to restrict the user while typing, then u need to add a keyPressed
or keyReleased event. it will validate every time u press or release the
key.
u can find the method signature and arguments in the Java doc API
http://java.sun.com/j2se/1.3/docs/api/