JComboBox的Java的自动完成 [英] Java JComboBox Autocomplete
问题描述
我有人民的ArrayList - 它是由一个名称,电子邮件,和几个数字(不过都是字符串)。我用这个列表来填充的JComboBox我的形式。
我想实现是自动完成的JComboBox,因此,例如,在添打字的时候:
preSST - >将下拉显示一切带T
开始preSS的i - >将下拉以钛
开始显示一切preSSM - >将下拉有添开头显示的一切
。我试过一些方法 - 看之类的东西SwingX,但似乎服务器下来,我无法访问任何文件。我曾尝试创建我自己的算法,但它变得相当复杂,我一直走下去的一些死角。我想知道如果任何人知道的任何好的方法来实现我想做?
感谢您。
我想知道是否有人知道的任何好的方法来实现我想做?
块引用>使用任何提供自动完成现有的库。 SwingX确实有这样的功能在API中,但其他人都可以使用。
看看的这篇文章其中包含的Java程序自动完成的详细信息,并包含链接到提供此功能的一些届党库
I have an ArrayList of People - which is made up of a Name, email, and a few numbers (however they are all strings). I use this list to populate a JComboBox on my form.
What I want to implement is an auto-complete JComboBox, so, for example, when typing in Tim:
Press "T" -> It will drop-down display everything beginning with "T"
Press "i" -> It will drop-down display everything that begins with "Ti"
Press "m" -> It will drop down display everything that has "Tim" at the beginning.
I've tried a few ways - looked at things like SwingX, but it seems that servers are down and I can't access any documentation. I have tried creating my own algorithm, but it's getting quite complicated and i've been going down some dead ends. I was wondering if anyone knew of any good methods to achieve what I am trying?
Thank you.
解决方案I was wondering if anyone knew of any good methods to achieve what I am trying?
Use any of the existing libraries that provide autocompletion. SwingX has indeed such a feature in the API, but others are available as well.
Take a look at this article which contains more information on autocompletion in Java and contains links to some 3th party libs which offer this functionality
这篇关于JComboBox的Java的自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!