简体   繁体   English

Java Swing Combobox 带自动完成和上下文菜单

[英]Java Swing Combobox with Autocomplete and Context Menu

I have auto complete for a JCombobox working by following this article:我按照这篇文章自动完成了一个 JCombobox 工作:

http://today.java.net/pub/a/today/2007/07/19/adding-auto-completion-to-swing-comboboxes.html http://today.java.net/pub/a/today/2007/07/19/adding-auto-completion-to-swing-comboboxes.html

I am using the SwingX library.我正在使用 SwingX 库。

Now I would like to add persistence support to the items in the combo box.现在我想为组合框中的项目添加持久性支持。 Basically when you right click an item a context menu comes up and you can remove the item.基本上,当您右键单击一个项目时,会出现一个上下文菜单,您可以删除该项目。 The same thing with the delete key.删除键也是如此。

To add an item the user just types a new entry which in not in the list yet.要添加一个项目,用户只需键入一个尚未在列表中的新条目。

I haven't found a way to hook up a context menu yet.我还没有找到连接上下文菜单的方法。

You can add key listener on combo box to look for delete key.您可以在组合框中添加键侦听器以查找删除键。 As for the popup, you'll have to implement it by yourself.至于弹出窗口,您必须自己实现它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM