Preventing the "lost focus" event to happen
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, May 16, 2001 10:29 AM

How can i prevent a component to dispatch the "lost focus" event?
I want to validate user input, if the input is not valid,the current component should not loss its focus.

Re: Preventing the "lost focus" event to happen

Posted By:   Finlay_McWalter  
Posted On:   Tuesday, June 12, 2001 05:45 PM

If you want to force focus to remain on a given control (which IMHO is really dreadful UI design) then you can catch the focusLost event and immediately call requestFocus() back on that control.

Re: Preventing the "lost focus" event to happen

Posted By:   AlessandroA_Garbagnati  
Posted On:   Wednesday, May 16, 2001 10:52 AM

Diego,

This it's probably stupid (my expertise is on the server side), but can't you just trap the "lost focus" event and then if the validation fails, send the focus back to the field?

Ciao!

Re: Preventing the "lost focus" event to happen

Posted By:   Christopher_Schultz  
Posted On:   Wednesday, May 16, 2001 10:51 AM

If you're able to use JDK 1.3 or better, look into InputVerifiers. They are a new (as of 1.3) addition to the javax.swing package.



They might be able to help you solve your problem.



-chris
About | Sitemap | Contact