如何清除 StyledDocument 中的所有样式? [英] How to clear all styling from StyledDocument?

查看:36
本文介绍了如何清除 StyledDocument 中的所有样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

StyledDocument 包含各种方法设置样式.像 setCharacterAttributes.

StyledDocument contains various methods to set styles. Like setCharacterAttributes.

但是我看不到任何删除样式的方法.

But I can't see any methods to remove styles.

有吗?

推荐答案

清除"样式是不可能的.应该使用以下技术获得默认"样式:

It is impossible to "clear" styles. One should obtain a "default" style with the following technique:

Style defaultStyle = StyleContext.
   getDefaultStyleContext().
   getStyle(StyleContext.DEFAULT_STYLE);

然后应用它:

sampleDocument.setCharacterAttributes(0, sampleDocument.getLength(), defaultStyle, true);

这篇关于如何清除 StyledDocument 中的所有样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆