java.lang.Object
javax.swing.text.StyleContext.NamedStyle
- 所有已实现的接口:
Serializable,AttributeSet,MutableAttributeSet,Style
- 封闭类:
StyleContext
属性的集合,通常用于表示字符和段落样式。这是 MutableAttributeSet 的一个实现,如果需要可以观察到。当集合足够小时,这些样式将利用不变性,并且可能比类似 SimpleAttributeSet 的东西更有效。
Warning: 此类的序列化对象将与未来的 Swing 版本不兼容。当前的序列化支持适用于运行相同版本 Swing 的应用程序之间的短期存储或 RMI。从 1.4 开始,对所有 JavaBeans 的长期存储的支持已添加到 java.beans 包中。请参阅 XMLEncoder 。
-
内部类总结
在接口 javax.swing.text.AttributeSet 中声明的嵌套类/接口
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute -
字段摘要
字段修饰符和类型Field描述protected ChangeEvent每个模型实例只需要一个 ChangeEvent,因为事件的唯一(只读)状态是源属性。protected EventListenerList模型的更改监听。在接口 javax.swing.text.AttributeSet 中声明的字段
NameAttribute, ResolveAttribute -
构造方法总结
构造方法构造方法描述创建一个新的命名样式,名称和父级为空。NamedStyle(String name, Style parent) 创建一个新的命名样式。NamedStyle(Style parent) 创建一个新的命名样式。 -
方法总结
修饰符和类型方法描述voidaddAttribute(Object name, Object value) 添加一个属性。voidaddAttributes(AttributeSet attr) 向元素添加一组属性。void添加更改监听。booleancontainsAttribute(Object name, Object value) 检查是否定义了给定的属性名称/值。booleancontainsAttributes(AttributeSet attrs) 检查元素是否包含所有属性。复制一组属性。protected void通知所有已注册对此事件类型的通知感兴趣的监听。getAttribute(Object attrName) 获取属性的值。int获取已定义的属性数。Enumeration<?>获取所有属性的名称。返回使用 addChangeListener() 添加到此 NamedStyle 的所有ChangeListener的数组。<T extends EventListener>
T[]getListeners(Class<T> listenerType) 返回添加到此模型的给定类型的所有监听的数组。getName()获取样式的名称。从父级获取属性。boolean检查给定的属性是否已定义。booleanisEqual(AttributeSet attr) 检查两个属性集是否相等。voidremoveAttribute(Object name) 从集合中移除一个属性。voidremoveAttributes(Enumeration<?> names) 删除元素的一组属性。voidremoveAttributes(AttributeSet attrs) 删除元素的一组属性。void删除更改监听。void更改样式的名称。voidsetResolveParent(AttributeSet parent) 设置解析父级。toString()将样式转换为字符串。
-
字段详细信息
-
listenerList
模型的更改监听。 -
changeEvent
每个模型实例只需要一个 ChangeEvent,因为事件的唯一(只读)状态是源属性。这里产生的事件源总是“this”。
-
-
构造方法详细信息
-
NamedStyle
创建一个新的命名样式。- 参数:
name- 样式名称,未命名为 nullparent- 父样式,如果没有则为 null- 自从:
- 1.4
-
NamedStyle
创建一个新的命名样式。- 参数:
parent- 父样式,如果没有则为 null- 自从:
- 1.4
-
NamedStyle
public NamedStyle()创建一个新的命名样式,名称和父级为空。
-
-
方法详情
-
toString
将样式转换为字符串。 -
getName
获取样式的名称。样式不需要命名,因此如果没有与样式关联的名称,则返回 null。 -
setName
更改样式的名称。对空名称不执行任何操作。- 参数:
name- 新名称
-
addChangeListener
添加更改监听。- 指定者:
addChangeListener在接口Style中- 参数:
l- 变化监听器
-
removeChangeListener
删除更改监听。- 指定者:
removeChangeListener在接口Style中- 参数:
l- 变化监听器
-
getChangeListeners
返回使用 addChangeListener() 添加到此 NamedStyle 的所有ChangeListener的数组。- 返回:
-
添加所有
ChangeListener或如果未添加任何监听器,则为空数组 - 自从:
- 1.4
-
fireStateChanged
protected void fireStateChanged()通知所有已注册对此事件类型的通知感兴趣的监听。事件实例是使用传递给 fire 方法的参数延迟创建的。- 参见:
-
getListeners
返回添加到此模型的给定类型的所有监听的数组。- 类型参数:
T- 监听器类型- 参数:
listenerType- 请求的监听器类型- 返回:
- 所有接收来自该模型的listenerType通知的对象
- 自从:
- 1.3
-
getAttributeCount
public int getAttributeCount()获取已定义的属性数。- 指定者:
getAttributeCount在接口AttributeSet中- 返回:
- 属性数 >= 0
- 参见:
-
isDefined
检查给定的属性是否已定义。- 指定者:
isDefined在接口AttributeSet中- 参数:
attrName- 非空属性名称- 返回:
- 如果定义了属性,则为真
- 参见:
-
isEqual
检查两个属性集是否相等。- 指定者:
isEqual在接口AttributeSet中- 参数:
attr- 要检查的属性集- 返回:
- 如果相同则为真
- 参见:
-
copyAttributes
复制一组属性。- 指定者:
copyAttributes在接口AttributeSet中- 返回:
- 副本
- 参见:
-
getAttribute
获取属性的值。- 指定者:
getAttribute在接口AttributeSet中- 参数:
attrName- 非空属性名称- 返回:
- 属性值
- 参见:
-
getAttributeNames
获取所有属性的名称。- 指定者:
getAttributeNames在接口AttributeSet中- 返回:
- 作为枚举的属性名称
- 参见:
-
containsAttribute
检查是否定义了给定的属性名称/值。- 指定者:
containsAttribute在接口AttributeSet中- 参数:
name- 非空属性名称value- 属性值- 返回:
- 如果定义了名称/值,则为真
- 参见:
-
containsAttributes
检查元素是否包含所有属性。- 指定者:
containsAttributes在接口AttributeSet中- 参数:
attrs- 要检查的属性- 返回:
- 如果元素包含所有属性,则为真
- 参见:
-
getResolveParent
从父级获取属性。如果没有被覆盖,解析父元素默认为父元素。- 指定者:
getResolveParent在接口AttributeSet中- 返回:
- 来自父级的属性
- 参见:
-
addAttribute
添加一个属性。- 指定者:
addAttribute在接口MutableAttributeSet中- 参数:
name- 非空属性名称value- 属性值- 参见:
-
addAttributes
向元素添加一组属性。- 指定者:
addAttributes在接口MutableAttributeSet中- 参数:
attr- 要添加的属性- 参见:
-
removeAttribute
从集合中移除一个属性。- 指定者:
removeAttribute在接口MutableAttributeSet中- 参数:
name- 非空属性名称- 参见:
-
removeAttributes
删除元素的一组属性。- 指定者:
removeAttributes在接口MutableAttributeSet中- 参数:
names- 属性名称- 参见:
-
removeAttributes
删除元素的一组属性。- 指定者:
removeAttributes在接口MutableAttributeSet中- 参数:
attrs- 属性- 参见:
-
setResolveParent
设置解析父级。- 指定者:
setResolveParent在接口MutableAttributeSet中- 参数:
parent- 父级,如果没有则为 null- 参见:
-