So I've created my own text pane class (extending JTextPane) and I'm using the method below to add text to it. However, the pane needs to be editable for it to add the text, but this allows a user to edit what is in the pane as well.
Can anyone tell me how to add text to the pane without letting the user manipulate what is there?
public void appendColor(Color c, String s) {
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
int len = getDocument().getLength();
setCaretPosition(len);
setCharacterAttributes(aset, false);
replaceSelection(s);
setCaretPosition(getDocument().getLength());
}