| 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: 18670
|
|
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: 18670
|
|
Isn't that what we're doing?
|
 |
 |
|
|
subject: How to create a color array?
|
|
|