Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Fubarable

Thread: How to use Validation API to validate Java Swing forms in Netbeans

  1. #1
    Riaz Ali is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default 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

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: How to use Validation API to validate Java Swing forms in Netbeans

    Moved from AWT/Swing

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    nverino is offline Member
    Join Date
    Jun 2012
    Posts
    1
    Rep Power
    0

    Default 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

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. how to do validation using java swing?
    By Vignesh Karthick in forum AWT / Swing
    Replies: 3
    Last Post: 01-25-2013, 02:38 PM
  2. Showing NetBeans-generated Swing forms
    By _SAS in forum AWT / Swing
    Replies: 0
    Last Post: 06-19-2010, 03:45 AM
  3. How do I validate user input from forms with Java?
    By rickywh in forum New To Java
    Replies: 2
    Last Post: 01-30-2010, 07:49 AM
  4. Replies: 2
    Last Post: 04-28-2008, 11:56 AM
  5. Creating Sub forms in java netbeans 5.0
    By java_newbie in forum NetBeans
    Replies: 14
    Last Post: 08-06-2007, 08:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •