• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JComboBox Keyboard Item Selection

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic