如何列出建议的文本字段中键入时 [英] How to list suggestions to when typing inside the text field

查看:121
本文介绍了如何列出建议的文本字段中键入时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Java Swing应用程序,您好我需要证明有相同的初始一切可能的现有条目
字符,而在文本字段中输入用户。可以说,在文本字段用户类型字母'A',这应该是一个国家的美和非洲将建议。以便用户可以选择一个从列表。国家名单驻留在我的数据库。我知道如何从数据库中检索数据。但我不知道该如何一一列举,哪些组件我应该使用来实现。
任何一个可以指导我?或者,如果你能提供一个例子,那将是巨大的。

Hi in my Java swing application I need to show all possible existing entries with same initial characters while user typing in a text field. Lets say user type letter 'A' in a text field which should be a country 'America' and 'Africa' would be suggestions. So that user can select one from the list. Country list resides in my database. I know how to retrieve data from DB. But I don't know how to list them and which components I should use to achieve. Can any one guide me? Or if you can provide an example, that would be great.

推荐答案

您可以使用autocomplete从包的SwingX。谷歌swingx自动完成,如果你需要更多的现实生活中的例子,但最简单的方法是创建一个的JComboBox 并调用
AutoCompleteDecorator.decorate(组合框);

You could use the autocomplete package from SwingX. Google for "swingx autocomplete" if you need more real life examples, but the simplest way is creating a JComboBox and calling AutoCompleteDecorator.decorate(comboBox); on it.

这篇关于如何列出建议的文本字段中键入时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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