如何制作用于搜索的文本字段(具有Google搜索之类的提示) [英] How to make a text field for searching(with tips like a google search)

查看:111
本文介绍了如何制作用于搜索的文本字段(具有Google搜索之类的提示)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java swing制作PC的窗口应用程序.我想在那里做一个文本字段.在输入该文本字段时,我需要它在该文本字段下显示提示.用户可以从列表中选择所需的文本.就像Google搜索在浏览器中一样.所以我需要两个函数,第一个很简单:通过已经键入的文本过滤一组字符串.但是如何在列表中显示它们呢?

I want to make a window application for PC using java swing. I would like to make a text field there. While typing to that text field I need it to show tips under that text field. And user can select the needed text from the list. The same like the google searching does in the browser. So I need some two functions, first one is easy: filter a set of strings by already typed text. But how to show them in a list ?

如果要在过滤后显示某些内容,则需要显示列表,并且需要使用向上和向下键进行选择.与Google搜索相同,但在PC应用程序上.

I need the list to be shown if there is something to show after filtration, and an ability to select by using keys up and down. The same as google search but on PC application.

推荐答案

常见选择为了这. AutoCompleteJComboBoxer 是我尝试过的.

JComboBox is a common choice for this. AutoCompleteJComboBoxer is one I've tried.

这篇关于如何制作用于搜索的文本字段(具有Google搜索之类的提示)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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