File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to catch the Tab key code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to catch the Tab key code" Watch "How to catch the Tab key code" New topic
Author

How to catch the Tab key code

satya sahu
Ranch Hand

Joined: Mar 26, 2003
Posts: 97
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

Joined: Apr 06, 2005
Posts: 44
Try
focusLost(FocusEvent e) method of java.awt.event.FocusAdapter


SCJP 2
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Check out InputVerifier. Class api has example code.
 
wood burning stoves
 
subject: How to catch the Tab key code
 
Similar Threads
Focusing Radio Button
Tab Key and KeyListeners
validate() Method in action form
Focus Lost Problem for JTextField
Validating empty JTextField Problem