• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to catch the Tab key code

 
satya sahu
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have to do some validation for few text fields. The validations are max,min range for integers and some string validations(no. of characters). All these validations should be done while tabbing out from a text field to another text filed. I am not able to get the Tab key code.
Is there any way i can catch the Tab out and do the validations. Say i enter something in the TextField1. If the input is not correct then show some message and the cursor should remain in the TextField1. If the input is correct then the control should go to the TextField2.
Please give me some sample code if available.
Thanks in advance.
 
Mudi Appu
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try
focusLost(FocusEvent e) method of java.awt.event.FocusAdapter
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out InputVerifier. Class api has example code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic