Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get the Red/Green or Blue level of a Component's Text Color !

Status
Not open for further replies.

khashyar7

Technical User
Aug 11, 2004
69
CA
Hi,

The getColorModel() method returns a ColorModel object, so I thought in the ColorModel class there would be a method that would return the RGB levels. There is, but it expect a Pixel object to be passed to it as an arguement, which does not make sence to me. I am invoking the method on a ColorModel object, so clearly I need to get the R/G/B levels of that ColorModel. How should I wrestle with this or do I have to take a totally different route !?

Lemmme know please.
 
Mmmm, I'm confused by your use of the ColorModel class, so I suspect there's more to your question than what's on the surface.

If you use the getForeground() method on a text component, it will give you the java.awt.Color object for the text colour. This class has getRed(), getGreen() and getBlue() methods.

Tim
 
Thanks Tim. I was just being stupid...Your suggestion worked perfectly !

Cheers,

Kash
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top