A JTextPane that shows styled text can’t take an AttributedString. You can’t get the string out of an AttributedString without iterating through it, because it doesn’t inherit from String. You can insert attributed text into a JTextPane, but only by giving it a String and an AttributeSet. You can’t get an AttributeSet out of an AttributedString, but you can get a map out of it. Which are two completely different things, it seems.