• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Using InputVerifier

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Maybe he went home and went to bed. And took this tiny ad with him:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic