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

Validating bookseats JTextField contents

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic