Reputation: 51219
StyledDocument contains various methods to set styles. Like setCharacterAttributes.
But I can't see any methods to remove styles.
Is there any?
Upvotes: 5
Views: 2294
Reputation: 51219
It is impossible to "clear" styles. One should obtain a "default" style with the following technique:
Style defaultStyle = StyleContext.
getDefaultStyleContext().
getStyle(StyleContext.DEFAULT_STYLE);
Then apply it with:
sampleDocument.setCharacterAttributes(0, sampleDocument.getLength(), defaultStyle, true);
Upvotes: 7
Reputation: 51559
StyledDocument has a removeStyle method that removes the named style.
Your document has to have character attributes. You can set the character attributes, and later set the character attributes to default values.
Upvotes: 1