• Post Reply Bookmark Topic Watch Topic
  • New Topic

textfield with drop down popup  RSS feed

 
Mikko Kohtamäki
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...
 
Michael Dunn
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!