This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

textfield with drop down popup  RSS feed

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am looking for an approach to how implement drop down popup for JTextField.

I have a class which maps characters and its root is TreeMap<Character, TreeMap>(myComparator). You add words in it and it has method java.util.List<String> getStrings(String startsWith).

When ever any readable character is typed in textfield it updates list model and shows it in drop down popup if any words matched for the query.

It would be nice if it wont require creating a new ui class. I have looked it in JComboBox perspective and figured that, i would have to create new combo box ui class, code new BasicComboPopup doing the listeners required by ComboPopup interface and replace the JList's model, JComboBox needs to be always in editing mode, editor would be textfield which manages the visibility of ComboPopup through KeyListener, maybe mouse and focus too.

Another approach could be BasicComboPopup alike class and manage it from JTextField.

Or what you would suggest to be better approach doing this ???

I would be thankful for any advice... haven't yet started coding it...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seems all you need to do is something like this


add your listeners to
- change the model
- show/hide the popup
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!