• Post Reply Bookmark Topic Watch Topic
  • New Topic

JCombo+JList problem

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im developing a chat application. I have a 'Send -to' JCombo box, which is populated with several 100 people who have logged into the chat. Now the JComboBox automatically listens to the 'first key char'. For instance if the JCombo contains the following names the respective order : Ajai, Ajith, Amar, Amay, Mary, Mathew...... etc. So when i type the letter 'A', focus automatically comes to Ajai, but to go to Amay i need to scroll 4 times. But instead if my combo could listen to several subsequent keys, like if i type 'A' follwed by 'm' and then 'a' (all continuosly) then focus could go to 'Amay'. How can i implement this feature. I thinks that this is quite a challenging issue. Can any of u people help me out please.
Its quite Urgent
Waiting for ur replies
regards
Saj
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sajee,
The tough part of that approach is when to start and stop listening. You would need some kind of timer between keys to avoid problems. For example:
Person1: find first A name, then sometime later find first B name, again later find first E name.
Person2: find first Ab name, then sometime later find first E name.
Person3: find first Abe name.
A program would need to distinguish between the three choices. It is analogous to multi-clicking mouse buttons.
When I have to do something like this I will use a textfield along with an associated list. That way the user can see the entire search string and can add or modify it whenever they want.
I can either use an input listener and search after each letter or use an action listener and search only when return is hit.
Regards,
Manfred.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!