2

I want to change selected text's color or to change highlighting color, and background in line numbers in RichTextFx, but I don't know how to do it, I need your help ! enter image description here

  • please have a look at https://github.com/FXMisc/RichTextFX/tree/master/richtextfx-demos and https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/MultiCaretAndSelectionDemo.java – guleryuz Sep 01 '18 at 17:26
  • and https://github.com/FXMisc/RichTextFX/wiki/RichTextFX-CSS-Reference-Guide – guleryuz Sep 01 '18 at 18:05

1 Answers1

4
.styled-text-area .selection {
    -fx-fill: pink;
}

save this as a file say styled-text-area.css

put this file in same package with your application class

in your class, import this file like

area.getStylesheets().add(getClass().getResource("styled-text-area.css").toExternalForm());

this will make selection color pink

by following here and adding related style rules in styled-text-area.css you can achieve your other needs.

guleryuz
  • 2,714
  • 1
  • 15
  • 19
  • 1
    Unfortunately, this does not seem to work for me... no change at all. I've overridden many other styles, and they work just fine. I wonder if there's another way. – user38725 Oct 13 '18 at 12:13
  • This only changes the highlighting color. But not the text color. – Franz Deschler Sep 01 '20 at 13:20