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.

The code below is a TableCellRenderer that shows a JProgressBar that can be used as a cell renderer in a JTable cell.

If you check the overridden getTableCellRendererComponent() method, the value should be a percentage value so that the JProgressBar can adjust its visual status according to the percentage.

Related Posts Plugin for WordPress, Blogger...