Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何让JCombobox 自动完成,它应该建议在字符串中的任何位置输入单词或短语的项目,而不仅仅是以该字符串开头。我正在使用eclipse juno IDE,解决方案应该支持 JDK 1.5
您可以实现自己的 KeySelectionManager ,当键入任何键时都会调用它。默认行为是选择以给定字符开头的条目,但您可以修改它以从 jcombo 框中的文本字段组件中获取当前文本,然后选择匹配的条目。
您将需要详细查看以下方法:
javax.swing.JComboBox.setKeySelectionManager(KeySelectionManager)