the title already describes my problem. I want to color single letters or sequences of letters in a JFX Button but not the whole text. I found a solution for swing components Is it possible to change the text color in a string to multiple colors in Java? but not for javafx yet. Can anyone help me plz?
Color Single Letters in JavaFX Buttontexts
1.5k Views Asked by gimba At
2
There are 2 best solutions below
0

This is just the FXML form of Uluk Biy's answer:
<Button>
<graphic>
<HBox spacing="0.0">
<Label text="Colors " style="-fx-text-fill: yellow; -fx-background-color: #1156cf;" />
<Label text="are " style="-fx-text-fill: red; -fx-background-color: #11cf56;" />
<Label text="cool!" style="-fx-text-fill: blue; -fx-background-color: #cf1156;" />
</HBox>
</graphic>
</Button>
...and yes, I love answering 7 years old questions. ;-)
Check this out
Output