2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by JustmeVSI
0

Hi. My problem i guess it is simple but i guess I'm simple as well :). The problem is the flowing: I have a JTextFead and a search method for IDs. The IDs are 7 char long. I want to be able when the user enters 7 chars the search method to be invoked. My first idea was a focus listener and a if statement if the chars are 7 then search, but that requires the txf to lose focus and on the regain then it searches. My other idea was to detect key events but niter is a good idea I guess =/.

Hello,

Key event will work fine from my point of view.

On every key event you can check if the length of value in JTextField is equal to 7.

Example :

if(jTextBoxObj.getText().length() == 7){
     doSearch();
}

Regards,

0

Hmmm ok tnx :). I just thought there is some smarter way of doing it but I guess it is ok as long as it works. Tnx again.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.