Search code examples
javafxrichtextfx

RichTextFX read-only?


I would like to use RichTextFX (StyledTextArea) to print standard output with error messages et al. I am already using it in it for my custom code editing, and It works well.

But how might I make the output "read only"? I would like the user to be able to mark text, copy-and-paste, interact with links and have hover-over popups etc. But not to be able to change the content of the output.

Should I perhaps implement some sort of change-listener which block/reverts any changes the user might (accidentally) make, or is there a simpler/more elegant solution?


Solution

  • StyledTextArea has a setEditable method, so calling setEditable(false) should do what you need.