Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use "Simple Validation API" to validate Java Swing forms in Netbeans

I have downloaded and installed the "Simple Validation" NetBeans Plug-in, 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 I should say); "ValidationPanel", "ValidationUtils" and "Problems". I saw an example at a website & 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"

I am sorry I think these are 2 questions, but kindly help me how to solve it.
Thanks in advance

like image 263
swdeveloper Avatar asked Nov 03 '22 23:11

swdeveloper


1 Answers

You just want the "ValidationPanel".

It seems to be called "org.netbeans.validation.api.builtin.stringvalidation.StringValidators" now.

final ValidationGroup group = validationPanel1.getValidationGroup();

group.add(txtUserName, StringValidators.REQUIRE_NON_EMPTY_STRING,
StringValidators.NO_WHITESPACE,
StringValidators.REQUIRE_VALID_INTEGER);
like image 92
Slacker_CA Avatar answered Nov 09 '22 12:11

Slacker_CA