Improving JComboBox

Hi,

Apologies in advance if this has been discussed before. I haven't found anything here or on google, but it may be because I haven't been using the right terms in the queries.

I'm looking for advice on how I might implement an improved version of a JComboBox, where instead of simply having a drop-down menu where you select an entry with your mouse, you are able to type in the combobox and it will sequence the list as you go. This would be useful in cases where you have a long list of usernames, for example, and you know you want to get to a name deep into the list. You could begin typing the username and it would jump to values that matched what you have typed. This seems like a common enough task, but I'm pretty new to the language and am at a loss as to how I might implement something of this nature. Any suggestions would be greatly appreciated. Thanks.

[893 byte] By [VP.a] at [2007-11-27 4:43:38]
# 1
Well, it has been discussed before, but over in the Swing forum where the question would naturally be asked. I think that "auto-complete" is a common term for what you described.
DrClapa at 2007-7-12 9:55:26 > top of Java-index,Java Essentials,Java Programming...
# 2

I have yet to try my hand with Swing. Without digressing too far from this forum's intended topic, would you mind answering a few questions?

Is it going to be possible to implement a Swing component like this in an existing GUI? I don't want to have to completely redesign this application's interface to implement this one component enhancement, although my guess is that this would need to be done.

If the answer above is that I would need to do a full redesign, do you think it would be possible to implement this component WITHOUT using swing? I recognize now that swing is definitely the "easy" way of doing something like this, but is it the ONLY way?

Thanks for your response.

VP.a at 2007-7-12 9:55:26 > top of Java-index,Java Essentials,Java Programming...
# 3
> Is it going to be possible to implement a Swing> component like this in an existing GUI? What GUI are you using?
petes1234a at 2007-7-12 9:55:26 > top of Java-index,Java Essentials,Java Programming...
# 4

Autocompleting textfields and comboboxes jump to the "first" entry that matches what has been entered (typed, pasted etc). The OP talks about resequencing (reordering?) the items as you go which sounds a little more general.

So long as an existing Swing GUI only uses the combobox properties of the widget there should be no reason why the GUI would have to change to accomodate the new behaviour.

I suppose it could be done without using Swing - but Swing offers the elements you need: A Document representing the currently entered text, and the ability to register DocumentListeners which can respond to changes in the text by filtering and sorting the elements of the combobox.

(The best place for help with this is the Swing forum.)

pbrockway2a at 2007-7-12 9:55:26 > top of Java-index,Java Essentials,Java Programming...
# 5
The gui now is AWT (I think that's the right term...), so I'm thinking I couldn't add a swing component to an awt gui...that's my guess at least.
VP.a at 2007-7-12 9:55:26 > top of Java-index,Java Essentials,Java Programming...
# 6
> so I'm thinking I couldn't add a swing component to an awt gui...that's my guess at leastThats correct, but your questions says you want to improve "JComboBox" which is a Swing component, so you question is very confusing.
camickra at 2007-7-12 9:55:26 > top of Java-index,Java Essentials,Java Programming...