I have a jtextpane I have alreadly colored in black, and red. Red is for the text inside the brackets. This seems to work, but the problem is when I insert text imediately next to a red bracket, the next text that comes out is red as well, while it should be black. Right now what I'm doing to fix the problem is coloring everything black first then color in the red, but that makes the jtextpane blinks between two colors. I was wondering if there is some simpler way to prevent the style from being "contagious".
Testing indicates that text added (by typing or pasting) within the style run takes on the red color and text added outside the run does not. The space immediately after the run appears to be counted as part of the run, ie, the beginning of the whitespace. The space after this is not, ie, the beginning of the next word.