Hopefully an easy question.
From the example on http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/combobox.html on “Providing a Custom Renderer” section, I can make a JComboBox like
Picture 3 - Text 3
-------------------
Picture 1 - Text 1
Picture 2 - Text 2
Picture 3 - Text 3
Picture 4 - Text 4
Picture 5 - Text 5
Where Picture 3 - Text 3 is the currently selected item.
Is it possible to have a custom label? Such as
Text 3
-------------------
Picture 1 - Text 1
Picture 2 - Text 2
Picture 3 - Text 3
Picture 4 - Text 4
Picture 5 - Text 5
Where the image is not displayed when the combo box is in it’s minimized state.
I’ve used a JButton/undecorated popup JFrame to emulate this before, but am wondering if it is possible to do with a pure JComboBox
Thanks
Yes. The same renderer is used to render the drop down list and the selected item in the combo box. The selected value is renderer when the “renderer index” is -1, so you can customize the rendering however you want. Something like: