1

Coming from PHP, using CodeIgniter, where handling form validation was simple as pie; I'm now looking for something similar to my Java application. (not a web-application, that is)

Sure, I can create my own methods which achieves this, and run it on the submit button's actionPerformed-event. However, that'd result in a lot of if(formElement.getText.isEmpty()) and so on.

Surely, there must be a better way to do this? Preferably without XML or a big clumpsy framework. I've only found frameworks which does this for Java web-applications. Thanks.

Zar
  • 6,786
  • 8
  • 54
  • 76
  • 1
    Are you using hibernate? They have a [Validation API](http://www.hibernate.org/subprojects/validator.html) and it's not only for web apps. –  Nov 23 '12 at 12:29
  • JSF 2 which is a part of Java EE 6 has form Validation. – AurA Nov 23 '12 at 12:35
  • 1
    I would not expect much really. First result in google "java swing validaton" led me to this old project: http://kenai.com/projects/simplevalidation/pages/Home – madth3 Nov 23 '12 at 13:11
  • 1
    In Swing the built-in support is rather limited. The best option is the `JFormattedTextField` (see [this example](http://stackoverflow.com/a/13424140/1076463)). If you could use 3th party libs, you could give the [validation framework of JGoodies](http://www.jgoodies.com/freeware/libraries/validation/) a try (I heard good things about it but no personal experience) – Robin Nov 23 '12 at 16:48

0 Answers0