Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using InputVerifier

 
Isaac Shabtay
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

anybody here used an InputVerifier when verifying input in a dialog?

Seems like a neat idea, but how would you overcome this?

1) User enters inappropriate data in a JTextField which has an InputVerifier associated with it.

2) User decides that he had enough of URLyBird for today and hits "Cancel".

3) Hitting "Cancel" causes Swing to attempt transferring the focus to the "Cancel" button, thus trying to validate the input field.

4) Validation of the input field fails, so focus stays on the JTextField.

Conclusion: User cannot exit the dialog.


Enlighten my way, please.
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Isaac
Why are you validating JTextField text when the cancel button is pressed?
I think verifying the data when the user press the ok button, not when the JTextField lose the focus is an easier path.
Regards
[ December 14, 2004: Message edited by: Ignacio del Valle ]
 
Isaac Shabtay
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ignacio del Valle:
Hello Isaac
Why are you validating JTextField text when the cancel button is pressed?
I think verifying the data when the user press the ok button, not when the JTextField lose the focus is an easier path.
Regards

[ December 14, 2004: Message edited by: Ignacio del Valle ]


I know it is an easier path. And that is the way I am currently implementing it. I was just considering to switch to using InputVerifier's, because, naturally, this is what SUN has provided for input validation. And this is the way that input validators work: They validate the data when the component loses focus.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic