colored JComboBox items?

I

Ian

Hi,
Is it possible to have a jcombobox with the items being actual colors(or at
leat the fonts) eg.

String[] myColors = { "Red", "Blue", "Yellow", "Orange", "White" };

JComboBox colorList = new JComboBox(myColors);

colorList.addActionListener(this);

But when the user clicks on the combobox instead of the names of the colors
being dislpayed each item is the appropriate color
Any help appreciated
 
C

Chris Smith

Ian said:
Is it possible to have a jcombobox with the items being actual colors(or at
leat the fonts) eg.

String[] myColors = { "Red", "Blue", "Yellow", "Orange", "White" };

JComboBox colorList = new JComboBox(myColors);

colorList.addActionListener(this);

But when the user clicks on the combobox instead of the names of the colors
being dislpayed each item is the appropriate color

This is what cell renderers are for. See the setRenderer method of
JComboBox.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top