How to use Validation API to validate Java Swing forms in Netbeans
I was searching for a Swing Forms Validation API in NetBeans and saw one at How to Quickly Add Validation Code to Swing UIs | Javalobby. I downloaded and installed the "Simple Validation" NetBeans Plug-in from Simple Validation: Downloads — Project Kenai, but do not know how to use it, because I cannot find where is it present (in toolbox).
Can anyone kindly help me by telling how where can I find it and what are the steps to apply the validation on my form fields.
I also saw there was a Validation API JAR file and I downloaded and included it in my project. It provided 3 controls (or whatever to call it); "ValidationPanel", "ValidationUtils" and "Problems". I saw an example & followed it. I dragged-and-dropped the "ValidationPanel" and wrote the code as shown in following code
final ValidationGroup group = validationPanel1.getValidationGroup();
group.add(txtUserName, Validators.REQUIRE_NON_EMPTY_STRING,
Validators.NO_WHITESPACE,
Validators.REQUIRE_VALID_INTEGER);
But it seems JAR file contains incomplete files or there may be other problem, because it gives error: cannot find symbol: variable "Validators"
When I wrote the code in NetBeans it gave same error for "ValidationGroup" class and when I clicked on a balloon on the left side of IDE it suggested me to import the package for it and when I clicked on it, it imported the package, but it does not suggest me to import package for "Validators"
I am sorry I think these are 2 questions, but kindly help me how to solve it.
Thanks in advance
Re: How to use Validation API to validate Java Swing forms in Netbeans
Re: How to use Validation API to validate Java Swing forms in Netbeans
Now you have to use StringValidators insted of Validators to get the validator constants.
group.add(txtUserName, StringValidators.REQUIRE_NON_EMPTY_STRING,
StringValidators.NO_WHITESPACE,
StringValidators.REQUIRE_VALID_INTEGER);
To use the merge method you have to use ValidatorUtils.merge(..)
I hope it helps you.
Norberto
Re: How to use Validation API to validate Java Swing forms in Netbeans
Post to re-activate an old thread deleted. Thread closed.