Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check the correctness of input?  RSS feed

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my programe if user input an invalid input I will check the correctness of user input one by one,then popup a dialog to show their invalid input. In this way I can't orgnize my code well, so many codes to check every where.
I want to know is there a framework to do this or some methords. How do you often do this?
Thank you in advance.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just my 2 cents:

you can have a validation method that returns a boolean: if false launch alert pop-up, else go on with your code
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could try:
JFormattedTextField with MaskFormatter
JTextField with extended PlainDocument, to filter the input
(e.g. see recent thread for zip code input)
http://www.coderanch.com/t/340971/GUI/java/Custom-Formats-JFormattedTextField
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently found this article on text validation. Has some other nice tips.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!