Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > colored JComboBox items?

Reply
Thread Tools

colored JComboBox items?

 
 
Ian
Guest
Posts: n/a
 
      04-13-2004
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


 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      04-13-2004
Ian wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to apply multi-colored innertext to <DIV> JM ASP .Net 2 09-21-2005 04:35 PM
Keep colored cells of my datagrid in memory Franck ASP .Net 5 06-27-2005 03:39 PM
Can I write colored letters with System.out.println? gajo Java 2 05-10-2004 09:53 PM
Semi-opaque colored background Brian Tozer HTML 11 02-09-2004 06:36 PM
[java2D] colored gradient markus brosch Java 7 08-19-2003 10:05 AM



Advertisments