GlazedLists 自动完成更改选择不起作用
我在项目中使用 GlazedLists (1.8) 库,但在组合框上使自动完成功能正常工作时遇到了问题。 我在 comboBox.getEditor().getEditorComponent()
上安装了一个 KeyListener
来捕获用户按下 Enter 键的时间,这样我就可以根据他们在组合框。
我将它安装在 JComboBox 上,并且过滤工作正常,但是当我使用箭头键更改选择时,对 comboBox.getSelectedItem()
的调用返回使用箭头键更改之前选择的内容选择。
此外,当发生这种情况时(使用箭头键),对 comboBox.getSelectedIndex()
的调用将返回 -1
。
我假设我不必处理关键事件来更改自己的选择(这应该是 GlazedLists 代码的一部分),所以有人知道这是一个错误还是我做错了什么? 我用谷歌搜索了一段时间,但没有发现这个错误。
编辑:我相当确定这是一个错误。 我尝试在 Windows 上运行它并且运行良好,但在 OS X 上似乎会卡住。OS X 的 LnF 似乎会在 GlazedLists 中引起很多错误。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否使用不受 GlazedLists 事件列表支持的组合框尝试过您的按键侦听器?
从你的描述来看,这听起来像是视图中的问题(或者只是事件触发的顺序,或列表锁定语义),而不是专门针对 GL 的问题......没有看到代码,很难说。
我建议您制作一个简短而甜蜜的示例应用程序来显示行为(或者更好的是单元测试 - 但这可能很难击键),然后发布到 GL listserv - 请务必包含信息Mac 与非 Mac 的比较。 当然,一旦您收到回复,请将其发布回此处以供后代使用:-)
您也可以在 mac 上尝试不同的 L&F(无论如何,我认为您可以这样做),看看问题是否仍然发生。 这至少可以让我们对可能发生的事情有一些了解。
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.