Showing posts with label Color from table?. Show all posts
Showing posts with label Color from table?. Show all posts

Tuesday, April 1, 2014

Color from table?
































































Hi,































































I'm trying to get background color from table of colors, but I can't.































Lets start with something like this:
































































































Java Code:






































































String colors[] = {"red","white","blue"};
Color selectedColor = Color.colors[1];




































































Returns:































































colors cannot be resolved or is not a field































I can use:
































































































Java Code:






































































String colors[] = {"red","white","blue"};
Color selectedColor = Color.red;




































































And it works. Bit while I'm trying to use table or variable it doesn't.































































How can I do this?































































K, solved.































































I can't belive noone anywhere didn't wrote it... Well, at least there where I have looked for it.































Solution:
































































































Java Code:






































































Color selectedColor[] = {Color.gray, Color.red, Color.black};
setBackground(selectedColor[0]);



































































































































Color from table?
































Hi,































I'm trying to get background color from table of colors, but I can't.















Lets start with something like this:
















































Java Code:





































String colors[] = {"red","white","blue"};
Color selectedColor = Color.colors[1];



































Returns:































colors cannot be resolved or is not a field















I can use:
















































Java Code:





































String colors[] = {"red","white","blue"};
Color selectedColor = Color.red;



































And it works. Bit while I'm trying to use table or variable it doesn't.































How can I do this?































K, solved.































I can't belive noone anywhere didn't wrote it... Well, at least there where I have looked for it.















Solution:
















































Java Code:





































Color selectedColor[] = {Color.gray, Color.red, Color.black};
setBackground(selectedColor[0]);


































































Color from table?
















Hi,















I'm trying to get background color from table of colors, but I can't.







Lets start with something like this:
























Java Code:




















String colors[] = {"red","white","blue"};
Color selectedColor = Color.colors[1];


















Returns:















colors cannot be resolved or is not a field







I can use:
























Java Code:




















String colors[] = {"red","white","blue"};
Color selectedColor = Color.red;


















And it works. Bit while I'm trying to use table or variable it doesn't.















How can I do this?















K, solved.















I can't belive noone anywhere didn't wrote it... Well, at least there where I have looked for it.







Solution:
























Java Code:




















Color selectedColor[] = {Color.gray, Color.red, Color.black};
setBackground(selectedColor[0]);

































Color from table?








Hi,







I'm trying to get background color from table of colors, but I can't.



Lets start with something like this:












Java Code:











String colors[] = {"red","white","blue"};
Color selectedColor = Color.colors[1];









Returns:







colors cannot be resolved or is not a field



I can use:












Java Code:











String colors[] = {"red","white","blue"};
Color selectedColor = Color.red;









And it works. Bit while I'm trying to use table or variable it doesn't.







How can I do this?







K, solved.







I can't belive noone anywhere didn't wrote it... Well, at least there where I have looked for it.



Solution:












Java Code:











Color selectedColor[] = {Color.gray, Color.red, Color.black};
setBackground(selectedColor[0]);
















Color from table?




Hi,



I'm trying to get background color from table of colors, but I can't.

Lets start with something like this:






Java Code:






String colors[] = {"red","white","blue"};
Color selectedColor = Color.colors[1];




Returns:



colors cannot be resolved or is not a field

I can use:






Java Code:






String colors[] = {"red","white","blue"};
Color selectedColor = Color.red;




And it works. Bit while I'm trying to use table or variable it doesn't.



How can I do this?



K, solved.



I can't belive noone anywhere didn't wrote it... Well, at least there where I have looked for it.

Solution:






Java Code:






Color selectedColor[] = {Color.gray, Color.red, Color.black};
setBackground(selectedColor[0]);