Form validation for JTextfield in Java?

Hoody picture Hoody · Jan 5, 2013 · Viewed 7.7k times · Source

Is there an easy way to validate a group of JTextFields in Java. I am currently using sqlite manager, neatbeans IDE to create a simple form that collects information to add a job into the database. I realise there is too many JTextFields. How can I validate each JTextFields either through sqllite throwing an exception error which can be customised, or maybe in Neatbeans through properties dialogue box. Validation is to be presence check, i.e. has a value been entered. Custom validation message?

Answer

trashgod picture trashgod · Jan 5, 2013

Use an InputVerifier, as shown in How to Use the Focus Subsystem : Validating Input. There's a related example here, among others.