🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #7790

Re: combobox font colour

#7790
From: Robert Crossman
Date: Mon, 18 Dec 2000 21:24
56 lines
2715 bytes
Try this:

    import javax.swing.JComboBox c;
    import java.awt.Color;

    // get the editor for the combobox and set its foreground color
    c.getEditor().getEditorComponent().setForeground(Color.blue);



Marty wrote:

> so how can i do that....  i have it set up as follows
>
> StandardComboBoxModel mLightsComboBoxModel = new StandardComboBoxModel();
>
> StandardComboBox lightsComboBox = new StandardComboBox
>                 (mLightsDisplayController.getLightsOptions());
>
> // find the current value....
> mLightsComboBoxModel.setSelectItem(mLightsDisplayController.getSelectedLight
> Colour());
>
> so if i get the text 'red' back, i would like this to be displayed in RED,
> green in GREEN etc....
>
> ps.... mLightsDisplayController is an instance of a class
> LightsDisplayController
>    ......getLightsOptions() populates the combobox with an array of objects
> (RED, AMBER, GREEN)
>     .....getSelectedLightColour() gets the current value selected
>
> hope someone can shed some 'light' on this for me
>
> thanks
> Martin
>
> "John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
> news:MPG.14a65ad9c5abd871989dc9@forums.borland.com...
> > On Fri, 15 Dec 2000 14:31:53 -0000, Marty wrote:
> >
> > > how do i set the colour of text (eg to RED) in a
> > > comboBoxModel?
> >
> > A ComboBoxModel is not a GUI component, so you cannot set the text
> > color there.  You would have to do it in the JComboBox that displays
> > the data of the ComboBoxModel.
> >
> > --
> > Regards,
> >
> > John McGrath [TeamB]
> >
> > ---------------------------------------------------
> > Before sending me e-mail, please read:
> >     http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <3A3E8083.94B514A9@metaserver.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!newsfeed.mesh.ad.jp!news.maxwell.syr.edu!sunqbc.risq.qc.ca!news.imp.ch!news-zh.switch.ch!newsfeed-zh.ip-plus.net!news.ip-plus.net!bornews.borland.com!dnews!206.97.11.162
References: <3a3a2aec_2@dnews> <MPG.14a65ad9c5abd871989dc9@forums.borland.com> <3a3dfc33_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,18e72797901060ea
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2000-12-18 13:30:29 PST
Message-ID: <3A3E8083.94B514A9@metaserver.com>
Date: Mon, 18 Dec 2000 16:24:19 -0500
From: Robert Crossman <crossman@metaserver.com>
X-Mailer: Mozilla 4.51 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: combobox font colour
References: <3a3a2aec_2@dnews> <MPG.14a65ad9c5abd871989dc9@forums.borland.com> <3a3dfc33_1@dnews>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 206.97.11.162
X-Trace: 18 Dec 2000 13:27:30 -0800, 206.97.11.162
Lines: 57
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!newsfeed.mesh.ad.jp!news.maxwell.syr.edu!sunqbc.risq.qc.ca!news.imp.ch!news-zh.switch.ch!newsfeed-zh.ip-plus.net!news.ip-plus.net!bornews.borland.com!dnews!206.97.11.162