2

I am new to JavaFX. I want to make the text of Label with different colors.

For Example:

Label : "sourav ganguly"

Ouput: sourav(as red color) ganguly(as blue color)

I tried but i didn't get it. Please can anyone help me.

naresh
  • 10,332
  • 25
  • 81
  • 124

1 Answers1

2

Or you could possibly use setStyle for Label and set the color you need.

label.setStyle("-fx-color: red");

see more

lummycoder
  • 588
  • 1
  • 7
  • 20
  • 4
    There is no css property like "-fx-color" in both 1.3 and 2.x JavaFX versions. Also the link you provided points to the old version of JavaFX. – Uluk Biy Jul 29 '13 at 11:11
  • Ooops))) [link](http://docs.oracle.com/javafx/2/ui_controls/label.htm) it could be better :) – lummycoder Jul 29 '13 at 12:37