• Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox Keyboard Item Selection

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right now, when you are in a JComboBox and you select a letter it takes you to the first item in the list with that letter. And then if you hit a different letter it again takes you to the item in the list beginning with that letter you typed.
What I am wondering, is if there is a way that when you type a key, it takes you to the first item in that list, but then if you type another key, it keys off the second letter in the items. So that if you just started typing a word then it would take you to that item in the List if it exists? I hope that makes since.
Thanks for any help.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg,
You can easily write your own selectionKeyManager but the problem you will encounter is when to reset the matching string. There is no way to tell when to reset it because you can only check for itemChanged or actionPerformed both of which happen many times during the course of matching. For example, the selectionKeyManager returns an index showing the matched string. The matched string is then automatically highlighted which creates an itemStateChanged event. The user hitting the return key creates an actionEvent which doesn't even account for mouse usage ...
By the time you are done, this little feature might take you weeks of coding ... time to figure out if it is worth the time.
Regards,
Manfred.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!