aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes validating user input for number of seats Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "validating user input for number of seats" Watch "validating user input for number of seats" New topic
Author

validating user input for number of seats

Rasika Chitnis
Ranch Hand

Joined: Jun 19, 2001
Posts: 131
What is the way to validate user input for number of seats obtained via a JOptionPane.showInputDialog ? I want to validate that user has entered only numeric. Do I have to write my own class that is a subclass of JDialog ?
Devu Shah
Ranch Hand

Joined: Jun 21, 2001
Posts: 50
hi rasika,
you can use the while loop i.e u get the user input and check whether it is numeric by catching the number format exception and if not than agian show the optionpane.
Originally posted by Rasika Chitnis:
What is the way to validate user input for number of seats obtained via a JOptionPane.showInputDialog ? I want to validate that user has entered only numeric. Do I have to write my own class that is a subclass of JDialog ?

Rasika Chitnis
Ranch Hand

Joined: Jun 19, 2001
Posts: 131
Devu,
Thanks. Yes, I already did that. But my validation code executes after user closes the dialog box. I want to do validation and display error message to user when the user clicks 'OK' button on the dialog box, but prevent the first dialog box from closing.
Narayan Veeramani
Greenhorn

Joined: Jun 06, 2001
Posts: 25
One approach is to extend JTextField and create your own
MaskEdit Field which only accepts numeric values. For this
you will need to override createDefaultModel() method &
return your own Document object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validating user input for number of seats