0

in my JAVA FX application I am using TextArea to display certain text content. I am using following property to restrict editing:

templateScriptArea.setEditable(false);

With this, user is not able to write anything on TextArea, but selection is allowed, or if any selection is made by application is able change by user. My requirement is that TextArea should be completely readonly, no editing no selection. Only scroll should work.

I thought, disabling TextArea is good idea with :

templateScriptArea.setDisable(true);

But, scroll not work with this and grey color appears on TextArea. Is there any better solution?

Sandeep Kokate
  • 825
  • 4
  • 16
  • Have you tried to put your textarea on a scrollpane? This way you should be able to use disable without wrecking the ability to scroll – Alexander Heim Sep 11 '17 at 10:06
  • @AlexanderHeim : Thanks for reply, I didn't try with that, actually TextArea is itself providing scrollbar when content is large. – Sandeep Kokate Sep 11 '17 at 10:41
  • Maybe you could add a `TextFormatter` that rejects any change. See: https://stackoverflow.com/questions/31039449/java-8-u40-textformatter-javafx-to-restrict-user-input-only-for-decimal-number Note that this will block programatically changing the text, so you may need to either set it after setting the text, or else have some flag. – Itai Sep 11 '17 at 10:43

0 Answers0