简体   繁体   中英

Java Swing Combobox with Autocomplete and Context Menu

I have auto complete for a JCombobox working by following this article:

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

I am using the SwingX library.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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