# Combobox autocomplete case indifferent

dastultz
797 8

Hello, I have a combobox with, say, one item "Fred". When I type "fr" it completes to "fred" which is OK, though I prefer "Fred". Then when I call combo.getSelectedItem() I get null. It seems "fr" matches "Fred" when autocompleting but "fred" does not match "Fred" when calling getSelectedItem(). I would think these should be consistent, no? (I've written a TypeConverter to get around it for now.)

/Daryl

delete retag edit

## 5 Replies

dennis
3669 1 6
http://www.javaworld.com....

Since Combobox is editable textbox, so I think the current behavior is OK.
For your issue, maybe it could provide a 'strict' feature to do auto-complete.

dastultz
797 8

Done.

http://sourceforge.net/tracker/index.php?func=detail&aid=2080644&group_id=152762&atid=785194

jumperchen
3909 2 8
http://jumperchen.blogspo...

Hi Dastultz,

You can use the constraint property to be strict, and this feature has implemented before.
For example,

<zk>
<zscript>
String[] data = new String[30];
for(int j=0; j < data.length; ++j) {
data = "Option "+j;
}
ListModel strset = new SimpleListModel(data);
</zscript>
<combobox id="list" width="200px" constraint="strict" model="\${strset}"/>
</zk>

You can also have a look at this article ListModel and Databinding Enhanced Combobox

dennis
3669 1 6
http://www.javaworld.com....

constraint="strict" , hmm.... I almost forgot it. :p

dastultz
797 8

Well, I thought I had it at strict, I do now, but maybe I didn't at the time. I'll take another look at it when I get a chance. I like the listmodel approach better, maybe I can get rid of my type converter then.

Thanks.

/Daryl

[hide preview]