I'm building a small conversation agent, where the text looks like follows:

![enter image description here](https://i.stack.imgur.com/9XTT1.jpg)

I would like to set the System's text to always be red. The text is all placed in a JTextPane.

How can I accomplish this? I have tried doing the following:

`agentTextPane.setForeground(Color.red);` after the system's text is added, and then switching back to black, however that changes all the text in the `JTextPane`.

This is how the system's text is added:

```
//'output' is a stringBuilder
output.append("\nSystem: ").append(tempOutput).append("\n");
agentTextPane.setText(output.toString());

```