Java Swing Combobox with Autocomplete and Context Menu
-
19-08-2019 - |
Question
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.
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow