swing 创建一个DefaultStyledDocument
示例
try {
StyledDocument doc = new DefaultStyledDocument();
doc.insertString(0, "This is the beginning text", null);
doc.insertString(doc.getLength(), "\nInserting new line at end of doc", null);
MutableAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setBold(attrs, true);
doc.insertString(5, "This is bold text after 'this'", attrs);
} catch (BadLocationException ex) {
//处理错误
}DefaultStyledDocuments可能是您使用最多的资源。可以直接创建它们,并StyledDocument抽象类的子类。
热门推荐
10 简短的爱情生日祝福语
11 生日祝福语男友妈妈简短
12 孩子新年祝福语简短精辟
13 学生国庆简短的祝福语
14 孙子生日祝福语简短精辟
15 元旦英文祝福语大全简短
16 退休的祝福语简短精辟
17 文艺乔迁祝福语简短精辟
18 简短搞笑蛋糕生日祝福语