JComboBox Tooltip

You wonder why there may be a need to have a tooltip inside a JComboBox. What if your item is very long like the image shown below?

This where tooltips come in handy unless you plan to have your JComboBox display items in multi-line if they are very long but that won’t look good. A tooltip is the best solution and the way to go about this is to assign a renderer to the JComboBox that does this.

This class does the trick. You only need to instantiate this and assign it to the JComboBox by calling the setRenderer() method.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *