0

I am trying to change the text of one word in a sentence and populate it to a JTextArea (Java Swing).

I have tried splitting the sentence based on white space to an array of words:

String[] words = message_textArea.getText().split(" ");

Then finding the starting and ending index of my word to use with SpannableString , but this only appears to be available with the android SDK.

Is there a alternative to the SpannableString in the java SDK? If not is there a means to change the colour of one word in a sentence in the java SDK?

Thanks

GeraldTDPI
  • 71
  • 11
dancingbush
  • 2,131
  • 5
  • 30
  • 66
  • Does this answer your question? [How to change text color in the JTextArea?](https://stackoverflow.com/questions/9650992/how-to-change-text-color-in-the-jtextarea) – Vladyslav Matviienko Nov 20 '19 at 10:36
  • Not quite, I had a look at the post, this is more detail on my issue https://stackoverflow.com/questions/58984995/jtextpane-cannot-render-a-concatenated-hmtl-string – dancingbush Nov 21 '19 at 22:57
  • I used solution for my issue here https://stackoverflow.com/questions/58991762/html-wrapped-string-creates-a-unwanted-new-line-in-jtextpane-output – dancingbush Nov 22 '19 at 20:14

0 Answers0