954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Message Dialog that prints a color variable's color

Hi, how would this work?

Color circleColor = Color.yellow;
JOptionPane.showMessageDialog(null, "The color of the circle is "+circleColor);

Doing this prints out the values of red green and blue that make what ever color the variable is, like it would show this: java.awt.Color[r=0,g=0,b=0], exept for yellow.
This is just an example of what I am trying to make work. The variable changes, which is why I need to do it this way instead of just saying "The color of the circle is yellow".

I have tried "The color of the circle is "+circleColor.toString()
and I have tried to use circle.Color.getColor()
but nothing works

warrior16
Newbie Poster
4 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

Why not make an inner class extend from the color class and overwrite the toString() method?

Alex Edwards
Posting Shark
972 posts since Jun 2008
Reputation Points: 392
Solved Threads: 109
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You