File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Validating bookseats JTextField  contents Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Validating bookseats JTextField  contents" Watch "Validating bookseats JTextField  contents" New topic
Author

Validating bookseats JTextField contents

Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
For Example,
In my gui the user has a field to input the number of seats he or she wishes to purchase I will compare the available seats that are availble first then how do I validate that the input data is a number and not a string or garbage???
I already have a BookSeat button with action event.

Thanks Lisa
Ken Zrobok
Greenhorn

Joined: Mar 08, 2001
Posts: 20
There are many ways to approach this. The core Java 2 vol 1 book has a section on consuming key events (ch. Event Handling), so as to disregard any key events that don't correlate to numbers
Or you can parse the trimmed input from the textbox and catch a NumberFormatException when the input is processed.
Ken


Ken Zrobok<BR>Java Developer/Trainer<BR>SCJP SCJD SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validating bookseats JTextField contents
 
Similar Threads
Assumptions about the GUI
Can't develop logic
lock & unlock
showInputDialog problem
help with program