Reputation: 4050
Everything is in the title, I need to highlight one letter in a label (the letter highlighted is not everytime the same)
it is like in old games when you enter your name with up/down arrows, the letter you are changing is highlighted.
Is there anyway to do this ? I could change to something else if label doesn't fit my need, but I have no clue on how to do this.
I read about CSS in Javafx but I don't get everything yet.
Upvotes: 0
Views: 1319
Reputation: 209339
In Java 8 you can use a TextFlow
, or use the RichTextFX third-party library.
Upvotes: 2
Reputation: 2006
I can't say for sure that there isn't some way to accomplish this with CSS trickery, but I'm not aware of any. If I were you, I would develop my own custom Node that either extends or composes HBox() (or class with similar left to right flow) and takes care of managing multiple labels to support your use case. Such a class could possibly represent each character with its own label instance, or perhaps just by using left, highlight and right labels, where left or right are empty when the left-most or right-most character are labeled, respectively. Your class could then define properties for the font, size, color etc, and a separate color to be applied to the 'highlighted' label.
Upvotes: 1