This week's book giveaway is in the Testing forum. We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line! See this thread 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.