Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to get the name of a Color object?

843805Apr 27 2006 — edited Apr 27 2006
Hello everyone,

I have an app that allows the user to define a Profile. They can select a text color (among other things). I am using a JColorChooser to set the color chosen by the user. The color is stored as an int value in the Profile object.
Once all items have been defined, the user clicks "Save" and their info is stored in the Profile object. At this point, I display a confirm dialog with a text representation of the data they've entered. i.e.
First Name: Joe
Last Name: Smith
Font Size: 12
Session Timeout: 30
Text Color: -13382401

This works fine for strings....I just call profile.getFirstName() to display the first name, etc. BUT, my problem is that profile.getColor() returns an int - and I don't want to display some funky int for the Color. I want to display something like "Black" or "Cyan" or "Light Gray".

There doesn't seem to be a way to extract a string representation from the Color object. Does anyone know an easy way to do this? The only thing I can think of right now is to hard code a map and use that to get my color names.

Thanks alot!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 25 2006
Added on Apr 27 2006
2 comments
126 views