Automatic search.

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2008
Posts: 3
Reputation: JustmeVSI is an unknown quantity at this point 
Solved Threads: 0
JustmeVSI JustmeVSI is offline Offline
Newbie Poster

Automatic search.

 
0
  #1
May 20th, 2009
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 =/.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 121
Reputation: puneetkay is on a distinguished road 
Solved Threads: 23
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Junior Poster

Re: Automatic search.

 
0
  #2
May 20th, 2009
Originally Posted by JustmeVSI View Post
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 :
  1. if(jTextBoxObj.getText().length() == 7){
  2. doSearch();
  3. }

Regards,
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer


Admin of Pikk - Object Relational Mapping Framework
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 3
Reputation: JustmeVSI is an unknown quantity at this point 
Solved Threads: 0
JustmeVSI JustmeVSI is offline Offline
Newbie Poster

Re: Automatic search.

 
0
  #3
May 20th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC