I have a JTextPane
that displays some text. It is generated dynamically. The program receives, from a socket, the style of the text and the text itself.
As an example, I want some parts of the text to be bold, some others to be centered, and some parts to be both bold and centered. I set a style with this code
doc.insertString(doc.getLength(), text, boldText);
Is there a way to do something like:
doc.insertString(doc.getLength(), text, boldText + centeredText);
I don't want to create a separate SimpleAttributeSet
for every combination of Style
s that I will need, as in the real program there will be many more options and it would be so hard to read plus it would drive me crazy.
Thanks
, but jTextPane is limited to html 3.2, and there are multiple things that I can't make with it. I would like to know if there is a way to do something like that without creating a new SimpleAttributeSet as you did, but there doesn't seem to be a way to do so. Thank you anyways :)
– Alex Ghilas Mar 18 '21 at 22:18