-
- All Superinterfaces:
-
Document
- 所有已知实现类:
-
DefaultStyledDocument,HTMLDocument
public interface StyledDocument extends Document
通用样式文档的接口。
-
-
字段汇总
-
Fields declared in interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
-
-
方法摘要
所有方法 实例方法 抽象方法 变量和类型 方法 描述 StyleaddStyle(String nm, Style parent)在逻辑样式层次结构中添加新样式。ColorgetBackground(AttributeSet attr)获取一组属性并将其转换为背景颜色规范。ElementgetCharacterElement(int pos)获取表示文档中给定偏移量处的字符的元素。FontgetFont(AttributeSet attr)获取一组属性并将其转换为字体规范。ColorgetForeground(AttributeSet attr)获取一组属性并将其转换为前景色规范。StylegetLogicalStyle(int p)获取段落中给定位置的逻辑样式。ElementgetParagraphElement(int pos)获取表示包含文档中给定偏移量的段落的元素。StylegetStyle(String nm)获取先前添加的命名样式。voidremoveStyle(String nm)删除先前添加到文档中的命名样式。voidsetCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)更改用于文档中给定范围的现有内容的内容元素属性。voidsetLogicalStyle(int pos, Style s)设置用于给定位置的段落的逻辑样式。voidsetParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)设置段落属性。-
声明方法的接口 javax.swing.text.Document
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeDocumentListener, removeUndoableEditListener, render
-
-
-
-
方法详细信息
-
addStyle
Style addStyle(String nm, Style parent)
在逻辑样式层次结构中添加新样式。 样式属性从下向上解析,因此子项中指定的属性将覆盖父项中指定的属性。- 参数
-
nm- 样式的名称(在命名样式的集合中必须是唯一的)。 如果样式未命名,则名称可以为null,但调用者负责管理返回的引用,因为无法通过名称获取未命名的样式。 未命名的样式可能对诸如样式运行中的字符属性覆盖之类的内容有用。 -
parent- 父样式。 如果不需要在某些其他样式中解析未指定的属性,则此值可能为null。 - 结果
- 风格
-
removeStyle
void removeStyle(String nm)
删除先前添加到文档中的命名样式。- 参数
-
nm- 要删除的样式的名称
-
setCharacterAttributes
void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)更改用于文档中给定范围的现有内容的内容元素属性。 给定Attributes参数中定义的所有属性都应用于给定范围。 此方法可用于通过提供未定义属性的Attributes参数并将replace设置为true来完全删除给定范围的所有内容级别属性。- 参数
-
offset- 更改的开始> = 0 -
length- 更改的长度> = 0 -
s- 要更改为的非null属性。 定义的任何属性都将应用于给定范围的文本。 -
replace- 指示在设置新属性之前是否应清除先前的属性。 如果为true,则操作将完全替换先前的属性。 如果为false,则新属性将与先前的属性合并。
-
setParagraphAttributes
void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)设置段落属性。- 参数
-
offset- 更改的开始> = 0 -
length- 更改的长度> = 0 -
s- 要更改为的非null属性。 定义的任何属性都将应用于给定范围的文本。 -
replace- 指示在设置新属性之前是否应清除先前的属性。 如果为true,则操作将完全替换先前的属性。 如果为false,则新属性将与先前的属性合并。
-
setLogicalStyle
void setLogicalStyle(int pos, Style s)设置用于给定位置的段落的逻辑样式。 如果没有为字符和段落属性显式设置属性,则它们将通过分配给段落的逻辑样式进行解析,而后者又可以通过某个层次结构完全独立于文档中的元素层次结构来解析。- 参数
-
pos- 起始位置> = 0 -
s- 要设置的样式
-
getLogicalStyle
Style getLogicalStyle(int p)
获取段落中给定位置的逻辑样式。- 参数
-
p- 位置> = 0 - 结果
- 风格
-
getParagraphElement
Element getParagraphElement(int pos)
获取表示包含文档中给定偏移量的段落的元素。- 参数
-
pos- 偏移量> = 0 - 结果
- 元素
-
getCharacterElement
Element getCharacterElement(int pos)
获取表示文档中给定偏移量处的字符的元素。- 参数
-
pos- 偏移量> = 0 - 结果
- 元素
-
getForeground
Color getForeground(AttributeSet attr)
获取一组属性并将其转换为前景色规范。 这可能用于指定更明亮,更多色调等内容。- 参数
-
attr- 属性集 - 结果
- 颜色
-
getBackground
Color getBackground(AttributeSet attr)
获取一组属性并将其转换为背景颜色规范。 这可能用于指定更明亮,更多色调等内容。- 参数
-
attr- 属性集 - 结果
- 颜色
-
getFont
Font getFont(AttributeSet attr)
获取一组属性并将其转换为字体规范。 这可用于将诸如族,样式,大小等内容转换为当前正在使用该文档的系统上可用的字体。- 参数
-
attr- 属性集 - 结果
- the font
-
-