nanda kumar
nanda kumar

Reputation: 31

How to color individual text values in the combo box on selection?

I'm able to add background color to my JComboBox in Swing (Java). How to color individual text values in the combo box when user selects those?

Upvotes: 0

Views: 62

Answers (1)

cybersoft
cybersoft

Reputation: 1473

You can implement ListCellRenderer interface or extend DefaultListCellRenderer to customize style of drop-down list items and set it:

jComboBox.setRenderer(new MyListCellRenderer());

Upvotes: 4

Related Questions