Changing the icon's color in a button

I’m using the RollPanel as a selector for different options : the panel’s title show the current option, and then content show (when displayed) the possible options, as buttons (a bit like the construction selector in the old simcity game)

The currently selected option has its text displayed in yellow, as shown here :

However, if i use the same kind of component with only the icon, and no text, then i got no color clues on the selected option (of course the icon is a clue in itself, but i whould like a remainder)

The Button class has a setColor(…) method, but this only change the text color. Is there any way to get the icon ? the getIcon returns a GFUIComponent, and not an IconComponent where the sertColor could be used.

Thanks in advance

Try to colour Einstein yellow:

As you might know/realize, you can’t without altering the picture. In computers, this means changing every pixel until it looks yellow. Nifty can’t do that. You need another, yellow picture for that.

…or create a font that uses these icons as characters (that’s how I did it)

Stupid of me.

While trying to show that you can indeed change the color of the icon (IconComponent has a method to do that), i’ve found that IconComponent is a child class of the GUIComponent.

Thus casting the result of button.getIcon() to an IconComponent works :

1 Like

Glad you figured it out. Note: you could also cast it to ColoredComponent which is the more general interface for components that let you set their color. Just in case you ever use a different component there someday. (shrug)

and yeah, setting the color is easy because JME’s shader already supports that.