JTextField的自动完成 [英] JTextField AutoComplete

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

问题描述

您好:如何添加自动完成字符串的JTextField中,从JTable中列获得汽车complte列表

  JTextField的文本框=新的JTextField();
JTable的表=新的JTable();


解决方案

借助 SwingX 图书馆有一个非常方便AutoCompleteDecorator功能。

假设你复制你的JTable列的值转换成一个ArrayList名为validValues​​。你现在需要对JTextField的myTextField将自动完成如下code:

  AutoCompleteDecorator.decorate(myTextField将,validValues​​,真正的);

第三个参数告诉自动完成装饰是否要严格匹配,即是否允许用户在JTable中列中输入之外的其他值或没有。

Hello: How to add AutoComplete String for JTextField, getting auto complte list from Jtable column.

JTextField textfield = new JTextField();
JTable table =new JTable();

解决方案

The SwingX library has a very handy AutoCompleteDecorator function.

Say you copy the values of your JTable column into an ArrayList called validValues. All you now need for autocompletion on the JTextField myTextField is the following code:

AutoCompleteDecorator.decorate(myTextField, validValues, true);

The third argument tells the autocomplete decorator whether you want strict matching, i.e. whether the user is allowed to enter values other than the ones in your JTable column or not.

这篇关于JTextField的自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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