• Post Reply Bookmark Topic Watch Topic
  • New Topic

question regarding JtextField for book seats??

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my JtextField I would like to check if a user has typed in something other then a number.
Forexample a user types by mistake 'w' instead of 3 how can I detect this error???
Thanks Lisa
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There's a example in Core Java vol 1 (chapter on swing).
It does'nt allow the user to type in anything other than a +ve integer.
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you karthik Guru, I found it: a little more then I expected but it is worth the general considerations points.
Thanks Lisa
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lisa,
Check out the creating a validated text field under this link: http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html
Rudy
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!