This week's book giveaways are in the Scala and Android forums. We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line! See this thread and this one for details.
Below is code for a class that implements javax.swing.event.DocumentListener that is intended to be used in conjunction with an editable javax.swing.JComboBox As you type into the text field, i.e. the editor component, the list of values in the popup automatically changes so as to display only those values that contain the text currently appearing in the text field.
For example if you type A, the popup displays all values that contain A.
If you type AB, the popup displays all values that contain AB.
Note that the listener is case sensitive. In other words, typing AB will not display values containing Ab or aB or ab.
Note that this is a first draft.
Also note that navigating the popup list via the keyboard may not be as you would expect.
Lastly, I make no promises or guarantees that I will respond to requests for modifying the below code.
In order to use the below class, add it as a DocumentListener to the javax.swing.text.Document associated with the JComboBox's editor component, e.g.
And here is the code for class DocLstnr
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it: