I have a JComboBox that is filterable and editable. I would like to set a tooltip for each item in the JComboBox - I figured I should use JToolTip for this.
I tried to use the answer from this link: Java Swing: Mouseover text on JComboBox items?.
But when the JComboBox shows filtered items, the order of the JToolTip index is changed. In this case I don't know how to set the right JToolTip text for each JComboBox item.
I would greatly appreciate it if you kindly give me some advice concerning to this problem.
How do you provide a tooltip if the combo box is editable and the user adds a new item to the combo box?
Don't base your lookup on index. Instead you need to base the lookup on the item (or toString() value of the item). For this you can use a
HashMapThen in the renderer you can use: