Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Multi-Color ListBox UICONTROL

Subject: Multi-Color ListBox UICONTROL

From: Gus

Date: 20 Feb, 2008 15:12:02

Message: 1 of 9

Is it possible to make the different lines of text in a
listbox style UICONTROL different colors?

cdata doesn't seem to do anything and backgroundcolor only
accepts a single 3-matrix RGB value.

Subject: Re: Multi-Color ListBox UICONTROL

From: Thomas Pieper

Date: 20 Feb, 2008 15:23:01

Message: 2 of 9

"Gus " <lottg.nospam@janelia.hhmi.org> wrote in message
<fphg02$iqr$1@fred.mathworks.com>...
> Is it possible to make the different lines of text in a
> listbox style UICONTROL different colors?
>
> cdata doesn't seem to do anything and backgroundcolor only
> accepts a single 3-matrix RGB value.

As far as I know (and I tried this very hard!), it's not
possible.

Subject: Re: Multi-Color ListBox UICONTROL

From: Gus

Date: 20 Feb, 2008 18:32:02

Message: 3 of 9

Thanks for the reply. This is what I figured.

Subject: Re: Multi-Color ListBox UICONTROL

From: Malcolm Lidierth

Date: 20 Feb, 2008 18:50:22

Message: 4 of 9

Try

h=uicontrol('style',...
'popupmenu',...
'String',...
{'<HTML><FONT COLOR=FF0000>Row 1</FONT><HTML>',...
'<HTML><FONT COLOR=0000FF>Row 2</FONT><HTML>'});

Subject: Re: Multi-Color ListBox UICONTROL

From: Yair Altman

Date: 20 Feb, 2008 19:03:23

Message: 5 of 9

"Thomas Pieper" <tom.pieper.nospam@t-online.de> wrote in
message <fphgkl$s67$1@fred.mathworks.com>...
> "Gus " <lottg.nospam@janelia.hhmi.org> wrote in message
> <fphg02$iqr$1@fred.mathworks.com>...
> > Is it possible to make the different lines of text in a
> > listbox style UICONTROL different colors?
> >
> > cdata doesn't seem to do anything and backgroundcolor only
> > accepts a single 3-matrix RGB value.
>
> As far as I know (and I tried this very hard!), it's not
> possible.


Actually, it's pretty easy using HTML:
uicontrol('Style','list', 'String', ...
   {'<HTML><FONT color="red">Hello</FONT></HTML>', ...
    'world', ...
    '<HTML><FONT color="blue">!!!</FONT></HTML>'} );

This is based on the undocumented fact that all Matlab GUI
components are based on Java Swing, which supports HTML
rendering.

Yair Altman
http://ymasoftware.com

Subject: Re: Multi-Color ListBox UICONTROL

From: Gus

Date: 20 Feb, 2008 19:34:02

Message: 6 of 9

Perfect! I am pleasantly surprised. This will make string
parsing a bit tougher, but it's exactly what I want. Thank
you all.

Subject: Re: Multi-Color ListBox UICONTROL

From: paladin34761

Date: 23 Jul, 2008 14:34:52

Message: 7 of 9

I tried the same thing for a multi-line text-box, without success ... any other ideas for this?

Thanks!

Subject: Re: Multi-Color ListBox UICONTROL

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 23 Jul, 2008 19:27:40

Message: 8 of 9

In article <26932051.1216823797684.JavaMail.jakarta@nitrogen.mathforum.org>,
paladin34761 <gfattinger@tqs.com> wrote:
>I tried the same thing for a multi-line text-box, without success ... any other ideas for this?

I believe that if you want a multi-color uicontrol('Style','text')
or uicontrol('Style','edit') then you will need to fiddle at the java
level.
--
   "I was very young in those days, but I was also rather dim."
   -- Christopher Priest

Subject: Re: Multi-Color ListBox UICONTROL

From: Yair Altman

Date: 24 Jul, 2008 16:41:02

Message: 9 of 9

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <g680nc$sm2$1@canopus.cc.umanitoba.ca>...

>>I tried the same thing for a multi-line text-box, without
>>success ... any other ideas for this?

> I believe that if you want a multi-color
uicontrol('Style','text')
> or uicontrol('Style','edit') then you will need to fiddle
at > the java level.

You can use JEditorPane or JTextPane: see
http://java.sun.com/docs/books/tutorial/uiswing/components/text.html
for an explanation, and my UIComponent
(http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14583)
for a sample integration with Matlab GUI.

Yair Altman

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
undocumented Yair Altman 20 Feb, 2008 14:05:09
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics