Form validation for JTextfield in Java?

Is there an easy way to validategroup JTextFieldsin Java. I am currently using sqlite managerit neatbeans IDEto create a simple form that collects information to add a job to the database. I understand that there are too many JTextFields. How can I check each JTextFields either through sqllite, throwing an exception error that can be configured, or maybe to Neatbeans through the properties dialog. Validation - check for availability, i.e. The value entered. User confirmation?

+5
source share
2 answers

Use InputVerifieras shown in How to use the focus subsystem: input validation . Here is an example here , among others .

+9
source

+1 t trashgods answer.

You can also use:

See here for an example and.

DocumentFilterallows you to check the text before displaying the changes, that is, by calling the super.XXXimplementation of the overridden method after successful verification of the text), where as DocumentListenerno. Usually in most cases it is better to settle for DocumentFilter.

See here for more details:

or alternatively:

  • JFormattedTextField . .
+5

Source: https://habr.com/ru/post/1541880/


All Articles