摆动自动填充文本字段/下拉 [英] swing autocomplete text field / drop down

查看:126
本文介绍了摆动自动填充文本字段/下拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要摆自动完成组件,与一个在JDesktop中的问题/ SwingX是,我们必须使用组合框,每个键中风后它只是向下滚动到最近的比赛,但在组合仍持有25.000元。它并不显示的4或5是因为它们一起可以是在列表中的不同位置的最接近的匹配。我们不希望以显示与列表中的25000要么...

We need an autocomplete component for swing, the problem with the one in jdesktop/SwingX is that we have to use a combo box and after each key stroke it simply scrolls down to the nearest match but the combo still holds the 25.000 elements. It doesn't show the 4 or 5 that are the closest match together because they can be in different places of the list. We don't want to display a list with the 25000 either...

有什么类似的JSF自动完成或一个在谷歌主页?我们需要的是要求我们的界面类似

Is there anything similar to the JSF autocomplete or the one in google main page? What we need is a component which asks our interface something like

公开名单getOptions(字符串typedSoFar){
  //这里我们根据我们的标准返还5匹配的人,只是提供了//用户这五个
}

public List getOptions(String typedSoFar) { //here we return the 5 matching ones according to our criteria and simply offers the //user those five }

推荐答案

一个非常简单的方法来做到这一点是使用GlazedList实现自动完成的。这是很容易得到启动和运行。你可以在这里找到它:

A really easy way to do this is to use the GlazedList implementation of auto-completion. It's very easy to get up and running. You can find it here:

http://publicobject.com/glazedlists/

您可以用釉上code只有一个行安装自动完成上的JComboBox,像这样的:

You can install the auto-complete on a JComboBox with only one line of Glazed code, like this:


JComboBox comboBox = new JComboBox();
Object[] elements = new Object[] {"Cat", "Dog", "Lion", "Mouse"};
AutoCompleteSupport.install(comboBox, GlazedLists.eventListOf(elements));

这篇关于摆动自动填充文本字段/下拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆