I have an indicator in my app, which has an icon (label) with a numeric value overlaid on it.
I want to bring attention to the fact the value changed, by changing the color of the label icon. I can do this by swapping out a different image made using a different color.
But I would like to return it back to its original color, and still see the color change and change back on the screen. I thought I might be able to use animation to do this, but I can't figure out how.
Update:
Applying Francesco's suggestion, like so:
replace(labelstd, labelhlt, CommonTransitions.createFade(500));
replace(labelhlt, labelstd, CommonTransitions.createFade(500));
I find that it does not fade to the highlight color, and then fade back, as I would like. It fades to the highlight color then instantly flips back. I assume that this is because the fades are actually happening in parallel.
Do I need to use threads to handle this, or is there another way to do this?
Label.setIcon(...)is not enough? Do you want something like a fade effect? In that case, there isContainer.replace(Component current, Component next, Transition t)that you can use to switch two Labels. As transition, you can useCommonTransitions.createFade(int duration)or any other transition provided by that class. - Francesco Galgani