Issue
I am new to RichTextFX and need some help. I want to use StyleClassedTextArea (see https://github.com/FXMisc/RichTextFX).
My simple java code:
public class GuiMain extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
StyleClassedTextArea styleClassedTextArea = new StyleClassedTextArea();
String exampleString = "This is a WARNING for an INFO! Please stay tuned";
styleClassedTextArea.appendText(exampleString);
styleClassedTextArea.setStyle(10, 16, Collections.singleton("-fx-font-weight: bold; -fx-highlight-fill: #B22224;"));
styleClassedTextArea.setEditable(false);
Scene scene2 = new Scene(new StackPane(styleClassedTextArea), 600, 400);
primaryStage.setScene(scene2);
primaryStage.setTitle("");
primaryStage.setMaximized(false);
primaryStage.show();
}
}
But when I run my java program, I just get the following:
However, as the picture shows, nothing is highlighted. Does anyone know how I can render the text in a certain range (from, to) in red (or what I have done wrong)?
Solution
For all of you who are facing the same problem:
Instead of -fx-highlight-fill, you can use RichTextFX with -rtfx-background-color: #...
Solution found here: Text background color in RichTextFx CodeArea
Answered By - zitrusire2520
Answer Checked By - Gilberto Lyons (JavaFixing Admin)