How can I change the caret color in JavaFX 2.0?

We want to port the project from Swing to JavaFX as a new UI technology. As part of our corporate design, we changed the caret color in Swing to light green.

How can we change the color (or maybe other things about appearance) of carets in JavaFX 2.0? I couldn't find any useful information on this. I saw that this is possible in earlier versions of JavaFX, so I think there is a 2.0 way too.

Respectfully,

David

+2


source to share


2 answers


In the frame, the TextField has the same color as the text. You can change them:

    TextField tf = new TextField("Text");
    tf.setStyle("  -fx-text-fill: green");

      



or globally in the css file.

+4


source


Sergey's answer should work fine .. However it doesn't work with texarea as it is a bug .. you can download java fx 2.1 developer preview to make it work with textarea



+2


source







All Articles