This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validating bookseats JTextField contents

 
Lisa Foster
Ranch Hand
Posts: 116
  • 0
  • 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
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic