Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus / Action / Key Listeners

Status
Not open for further replies.

k4ghg

Technical User
Dec 25, 2001
191
US
Hi - I have 4 JTextArea in a frame. I an try to add a listener so if text area 2 loses focus, the input would be check and if it meets a certain condition the focus would go to text area 4.

Do I need a key listener or an event listener? Also how do I create the handler? Does it need to be a class? Any help would be appreciated. Thanks - Ronnie
 
Implementing a focusListener per JComponent although works for a limited nos of components, is quite long and drawn out when you have many fields to provide validation.

Why don't you use an InputVerifer class, you can then centralise all your validation logic in one place and do not need to have loads of component.addXXXXListener(...) methods.
 
Yes, I recently made use of the (new in 1.4) InputVerifier class and it works a treat.

Tim
 
Forgive me if i'm wrong but I recall using the InputVerifier class since release v1.3 ?
 
Well spotted. It was introduced in 1.3. That's what comes with being too busy to check my facts and trusting to memory.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top