Java的自动完成文本字段(阿贾克斯风格)字段、自动完成、文本、风格

2023-09-10 21:17:39 作者:冷攻心。

我需要创建一个JTextField(或任何组件在那里我可以输入一些东西),它必须提供dynamicaly填充值的列表。当我输入一个新的角色,命题被更新(如AJAX一样)

I need to create a JTextField (or any component where I can type something) and it has to offer a list of dynamicaly populated values. When I type a new character, the propositions are updated (Like Ajax does)

一特点是,用户只能选择被填充的值。我需要为我的用户从数据库中选择一个现有的城市。

One particularity is that the user can only choose a value that was populated. I need that for my users to select an existing city from a database.

什么是与摆动使其成为最简单的方法是什么?

What would be the easiest way to make it with Swing ?

感谢你。

推荐答案

我已经使用了 JIDE常见层的自动完成在的Java Swing。看看在 Webstart的演示。

I have used the JIDE Common Layer for autocompletion in Java Swing. Take a look at the WebStart demo.

这是免费的,开源的,如果提供的自动完成选项不完全匹配,你正在做什么,我发现它真的很容易在自己的逻辑来堵塞。

It's free and open source, and if the provided autocompletion options don't quite match what you are trying to do I found it really easy to plug in my own logic.