Perry Smith

Java Questions & Answers

Home / Java Q & A Page 2 / Java Q & A Archive Main Page

10-3-98

Help on Focus Events!!!

I am working with focusGained and focusLost events, I think I understand their purpose, but I just cannot get them to send out the focus automatically. I mean, If I´m receiving input on a text field, I would like the focus to be sent to the next component inmediately after I type the last character possible without having to click the mouse, hit the enter key or the tab key. How do I get it to do it automatically?

Gwen Hernandez


Response
10-3-98 Re: Help on Focus Events!!!

you don't need the focusGained() or focusLost() methods ... what you'll need is a KeyEventListener attached to your text box that checks the length of the string in the text box every time a key is pressed. When the legnth equals whatever the maximum is supposed to be you would want to invoke the requestFocus() method of the next component. Good luck.

MikeD


Home / Java Q & A Page 2 / Java Q & A Archive Main Page