I am developing a Java Swing Application.
The application ends with a form to take the customers information (name, last name, email, gender, etc)
I am trying to validate the text fields in a way that when the application is launched focus will go on the first text box (first name). I want the user to not be able to leave the box until they have entered a valid name (no numbers, punctuation and so on).
So far I am using JOptionPane.showMessageDialog(null, "")
to output messages to the user, and the textfields are rigged with lost focus listeners.
Unfortunately even after looking online, I am not able to find a solution to validating these boxes.
Action Plan:
Focus on first textfield >>> Unable to leave unless valid input is entered >> messages outputted to user >> validation completed >> focus set on next field >> and so on.
Help would be appreciated.