File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to create a color array? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to create a color array?" Watch "How to create a color array?" New topic
Author

How to create a color array?

Samuel Fitzpatrick
Greenhorn

Joined: Jan 23, 2003
Posts: 10

Question: I am trying to declare and assign values to a color array using sRGB values in one line.
I have found that
Color[] c1 = {Color.RED,Color.WHITE,Color.BLUE};
works.
But how do I get
Color[] c2 = {(255,0,0),(255,255,255),(0,0,255)};
to work?
Currently I have
Color[] c3 = new Color[3];
...
c3[0] = new Color(255,0,0);
c3[1] = new Color(255,255,255);
c3[2] = new Color(0,0,255);
but, would like this in one line. Thanks.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Well, there's

But that's as compact as it gets, I think.


"I'm not back." - Bill Harding, Twister
Samuel Fitzpatrick
Greenhorn

Joined: Jan 23, 2003
Posts: 10

thanks, that was exactly what I was looking for.
Robbie shi
Greenhorn

Joined: Jan 05, 2003
Posts: 28
Color[] c2 = {new Color(255,0,0),new Color(255,255,255),new Color(0,0,255)};
you should use constructor
Color(int ,int,int)
----
Robbies
-----------------------------
1.java IDE tool : JawaBeginer
2.Java Jar tool : JavaJar
http://www.pivotonic.com
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Isn't that what we're doing?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to create a color array?
 
Similar Threads
Colour Mixing
Populating panels with buttons using loops.
JSP + Jfreechart
Convert Color (RGB) to Hex
XSL-FO to PDF using fop