Search code examples
javajavafxjavafx-8richtextfx

Set text of StyleClassedTextArea programmatically


The RichTextFX library has a nice StyleClassedTextArea which fits my use case nicely.

However, I can't find a way of programmatically setting the text on it - I can get it fine, and type, but can't find any way of altering it.

I presume there's something big I'm missing but can't quite work it out! Any pointers?


Solution

  • You can use the replaceText(start, end, text) method. If start==end this will work as an insert; if start==end==getLength() as an append, if text.equals("") as a delete, etc.