views:

110

answers:

1

I am using the GlazedLists (1.8) library in my project, and I have been having trouble getting autocomplete working properly on my combo boxes. I installed a KeyListener on comboBox.getEditor().getEditorComponent() to catch when a user hits enter, so that I can do something based on what item they select in the combo box.

I installed it on the JComboBox fine, and filtering works, but when I use the arrow keys to change the selection a call to comboBox.getSelectedItem() returns what was selected before using the arrow keys to change the selection.

Also, when this happens (using the arrow keys), a call to comboBox.getSelectedIndex() returns -1.

I would assume that I don't have to deal with key events to change the selection myself (that should be a part of GlazedLists' code), so does anyone have any idea if this is a bug or if I am doing something wrong? I googled for a while but didn't find this bug.

EDIT: I am fairly sure this is a bug now. I tried running it on Windows and it worked fine, but it seems to choke on OS X. OS X's LnF seems to cause a lot of bugs in GlazedLists.

A: 

Have you tried your keylistener with a combobox that isn't backed by a GlazedLists eventlist?

From what you describe, it sounds like an issue in the view (or just the order of when events fire, or list locking semantics), rather than an issue with GL specifically... Without seeing the code, it's hard to say.

I'd suggest that you put together a short and sweet sample app that shows the behavior (or even better, a unit test - but that might be hard with the keystroke), and post to the GL listserv - be sure to include the info of mac vs non-mac. Of course, once you have a response, post it back here for posterity :-)

You could also try a different L&F on the mac (I think you can do that, anyway) and see if the problem still happens. That at least would provide some insight into what may be going on.

Kevin Day