Changing the color of a label

Hi everyone, I’ve got a tiny issue at hand. I’m trying to change the color of a text label through Java. Now I know you can change the color of a text label in XML but I want to change the color of the label while some sort of function is called.
Above as an example of how to change the color, but it only supports 2 different colors which is black or white as well as a random color. How do you change the color to red or any other color than black and white using the code above? Or is there a better way to change the color?

Any help or tips will be appreciated.

See if you can pass in a new Color object, and pass color data in the constructor (haven’t checked this)

1 Like

Hi Wesley, thanks for the reply. That works, I created a new Color object and then I pass color data in the constructor as such:
Color color = new Color(Color.NONE);
After that I assigned the color by changing it’s RGB value. I also set the value of ‘alpha’ to one otherwise you can’t see the color (not necessary for 'BLACK or 'WHITE colors).

Thanks again for the reply! I always learn something new when I visit this forum.