The core Swing library doesn't have this functionality, but, it's a very
popular feature and I'm pretty sure you should be able to find plenty of
free and/or commercial implementation. Look for "incremental search."
If you'd rather implement it yourself, here's a general description of what
you need to do:
1. Create a custom ComboBox (e.g. FilteredComboBoxModel) model (by
subclassing AbstractListModel) that can take a string and expose only those
elements that start with that string.
1. subclass JComboBox
2. In the constructor
a. set the combo box to use your custom data model (e.g. setModel(
filteredBoxModel) )
b. assign a document listener to the combo box's editor component's
document ( e.g.
((JTextField)getEditor().getEditorComponent()).getDocument().addDocumentListener(...)
)
c. every time the document listener gets an event, get the text string
from the editor and pass it to the model
If you don't want to use a combo box, you can use the same technique with a
plain JTextiField and a JList. The only trick here is that you'd have to
add the list component to the palette layer of the underlying JFrame or
JApplet (if you need more help with this part, let me know).
Dmitry
At 01:04 PM 2/15/2002, Alex Kravets wrote:
>Does anybody know a way to utilize in Java Swing an ability ro pop-up a
>box when someone starts typing. For example in Java Forte, when you start
>to type "JTextField", IDE pops-up a box that shows all available
>constructors for this component. I want to do the same thing for my
>applcation, where I have about 100,000 unique IDs, so that when a users
>starts to type ID in a JTextField, a box appears with a list of IDs close
>to what he started typing. So if my list of IDs is 00222, 00223, 00224 and
>01333 and a user types in 00, then a box will pop up with IDs that have
>this substring "00".
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing