java.lang.Object
javax.swing.text.StyleContext.NamedStyle
- 所有已实现的接口:
-
Serializable,AttributeSet,MutableAttributeSet,Style
- 封装类:
-
StyleContext
一组属性的集合,通常用于表示字符和段落样式。这是MutableAttributeSet的实现,如果需要可以进行观察。这些样式将在集合足够小的情况下利用不可变性,并且可能比SimpleAttributeSet之类的东西更有效率。
警告: 该类的序列化对象将不兼容未来的Swing版本。当前的序列化支持适用于短期存储或在运行相同Swing版本的应用程序之间的RMI。从1.4开始,已将对所有JavaBeans的长期存储支持添加到java.beans包中。请参见XMLEncoder。
-
Nested Class Summary
Nested classes/interfaces declared in interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChangeEvent模型实例只需要一个ChangeEvent,因为事件的唯一(只读)状态是源属性。protected EventListenerList模型的更改监听器。Fields declared in interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute -
Constructor Summary
ConstructorsConstructorDescription创建一个新的命名样式,具有空名称和父样式。NamedStyle(String name, Style parent) 创建一个新的命名样式。NamedStyle(Style parent) 创建一个新的命名样式。 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(Object name, Object value) 添加一个属性。voidaddAttributes(AttributeSet attr) 向元素添加一组属性。void添加一个更改监听器。booleancontainsAttribute(Object name, Object value) 检查给定的属性名称/值是否已定义。booleancontainsAttributes(AttributeSet attrs) 检查元素是否包含所有属性。复制一组属性。protected void通知所有已注册对此事件类型感兴趣的监听器。getAttribute(Object attrName) 获取属性的值。int获取已定义的属性数量。Enumeration<?> 获取所有属性的名称。返回添加到此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()将样式转换为字符串。
-
Field Details
-
listenerList
模型的更改监听器。 -
changeEvent
模型实例只需要一个ChangeEvent,因为事件的唯一(只读)状态是源属性。这里生成的事件的源始终是"this"。
-
-
Constructor Details
-
NamedStyle
创建一个新的命名样式。- 参数:
-
name- 样式名称,如果未命名则为null -
parent- 父样式,如果没有则为null - 自1.4版本起:
- 1.4
-
NamedStyle
创建一个新的命名样式。- 参数:
-
parent- 父样式,如果没有则为null - 自1.4版本起:
- 1.4
-
NamedStyle
public NamedStyle()创建一个新的命名样式,具有空名称和父样式。
-
-
Method Details
-
toString
将样式转换为字符串。 -
getName
获取样式的名称。样式不需要具有名称,因此如果样式没有关联的名称,则返回null。 -
setName
更改样式的名称。如果名称为null,则不执行任何操作。- 参数:
-
name- 新名称
-
addChangeListener
添加一个更改监听器。- 指定者:
-
addChangeListener在接口Style - 参数:
-
l- 更改监听器
-
removeChangeListener
删除一个更改监听器。- 指定者:
-
removeChangeListener在接口Style - 参数:
-
l- 更改监听器
-
getChangeListeners
返回添加到此NamedStyle的所有ChangeListener的数组。- 返回:
-
所有已添加的
ChangeListener或空数组(如果未添加任何监听器) - 自1.4版本起:
- 1.4
-
fireStateChanged
protected void fireStateChanged()通知所有已注册对此事件类型感兴趣的监听器。事件实例是使用传递给fire方法的参数延迟创建的。- 参见:
-
getListeners
返回添加到此模型的给定类型的所有侦听器的数组。- 类型参数:
-
T- 监听器类型 - 参数:
-
listenerType- 请求的监听器类型 - 返回:
- 所有从此模型接收listenerType通知的对象
- 自1.3版本起:
- 1.3
-
getAttributeCount
public int getAttributeCount()获取已定义的属性数量。- 指定者:
-
getAttributeCount在接口AttributeSet - 返回:
- 属性数量 >= 0
-
isDefined
检查给定属性是否已定义。- 指定者:
-
isDefined在接口AttributeSet - 参数:
-
attrName- 非null属性名称 - 返回:
- 如果属性已定义,则为true
-
isEqual
检查两个属性集是否相等。- 指定者:
-
isEqual在接口AttributeSet - 参数:
-
attr- 要检查的属性集 - 返回:
- 如果相同,则为true
-
copyAttributes
复制一组属性。- 指定者:
-
copyAttributes在接口AttributeSet - 返回:
- 复制品
-
getAttribute
获取属性的值。- 指定者:
-
getAttribute在接口AttributeSet - 参数:
-
attrName- 非null属性名称 - 返回:
- 属性值
-
getAttributeNames
获取所有属性的名称。- 指定者:
-
getAttributeNames在接口AttributeSet - 返回:
- 属性名称的枚举
-
containsAttribute
检查给定属性名称/值是否已定义。- 指定者:
-
containsAttribute在接口AttributeSet中 - 参数:
-
name- 非空属性名称 -
value- 属性值 - 返回值:
- 如果定义了名称/值,则返回true
- 参见:
-
containsAttributes
检查元素是否包含所有属性。- 指定者:
-
containsAttributes在接口AttributeSet中 - 参数:
-
attrs- 要检查的属性 - 返回值:
- 如果元素包含所有属性,则返回true
- 参见:
-
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 - 参见:
-