• Post Reply Bookmark Topic Watch Topic
  • New Topic

Autocomplete in JTextField

 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been reading several suggested solutions for implementing autocomplete for a JTextField. However, the documentation is a bit confusing to me. It seems like they mostly require switching to a JComboBox. Can I or can I not continue to use a JTextField and implement an autocomplete feature? I also saw what I thought was a built-in autocomplete "decorator" for swing objects (although it was not clear if it can be used for JTextField) but most of the implementations seem to start from scratch. Can someone clarify the best and simplest way to implement this (assuming those 2 conditions are not mutually exclusive)? TIA.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One obvious advantage of using (an editable) JComboBox is you need not worry about the drop down, word matching etc. If you roll out your own using only a JTextField, you will need to code for all these. What is wrong in using a JComboBox?
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. I have nothing against using JComboBox but it was not clear, from what I read, if that was necessary. That is what I am trying to clarify as my application already uses JTextField. If switching to JCombBox makes life easier then I am all for it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!