Forum Stats

  • 3,854,961 Users
  • 2,264,441 Discussions


Is it possible to paint a background color for a Text in Javafx 8?

1056224 Member Posts: 6
edited Feb 12, 2014 2:57AM in JavaFX 2.0 and Later


we are currently designing an application where the user imports some text which is then analyzed for specific keywords. These keywords should then be highlighted in the text so that the user can easily see which words have been found.

Now with Java 8 we'd like to use the new TextFlow class for this. I know that I can easily change the font of the words that have been identified, but it would also be nice if I could add a background color for even easier visual scanning of the text. Is there anyway how to achieve this using the Text class? I know that I could also add a label to the TextFlow, however this would break the flow of the Text because sometimes we also need to highlight larger parts of the text, and if that text extends beyond the end of the line the linkebreaks will just be hideous.

I already thought about subclassing Text and a background, but simply do not know where I would have to change the way how the rendering happens.

Any tips would be appreciated


Best Answer


This discussion has been closed.