- java.lang.Object
-
- javax.swing.text.StyleContext.NamedStyle
-
- 实现的所有接口
-
Serializable,AttributeSet,MutableAttributeSet,Style
- Enclosing class:
- StyleContext
public class StyleContext.NamedStyle extends Object implements Style, Serializable
一组属性,通常用于表示字符和段落样式。 这是MutableAttributeSet的一个实现,如果需要可以观察它。 这些样式将利用不变性,而集合足够小,并且可能比SimpleAttributeSet更有效。警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,对
java.beans软件包中添加了对所有JavaBeansjava.beans长期存储的支持。 请参阅XMLEncoder。- 另请参见:
- Serialized Form
-
-
嵌套类汇总
-
Nested classes/interfaces declared in interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
-
-
字段汇总
字段 变量和类型 字段 描述 protected ChangeEventchangeEvent每个模型实例只需要一个ChangeEvent,因为事件的唯一(只读)状态是source属性。protected EventListenerListlistenerList模型的更改侦听器。-
Fields declared in interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
-
-
构造方法摘要
构造方法 构造器 描述 NamedStyle()创建一个新的命名样式,使用空名称和父项。NamedStyle(String name, Style parent)创建一个新的命名样式。NamedStyle(Style parent)创建一个新的命名样式。
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 voidaddAttribute(Object name, Object value)添加属性。voidaddAttributes(AttributeSet attr)向元素添加一组属性。voidaddChangeListener(ChangeListener l)添加更改侦听器。booleancontainsAttribute(Object name, Object value)检查是否定义了给定的属性名称/值。booleancontainsAttributes(AttributeSet attrs)检查元素是否包含所有属性。AttributeSetcopyAttributes()复制一组属性。protected voidfireStateChanged()通知所有已注册对此事件类型的通知感兴趣的听众。ObjectgetAttribute(Object attrName)获取属性的值。intgetAttributeCount()获取已定义的属性数。Enumeration<?>getAttributeNames()获取所有属性的名称。ChangeListener[]getChangeListeners()返回使用addChangeListener()添加到此NamedStyle的所有ChangeListener的数组。<T extends EventListener>
T[]getListeners(类<T> listenerType)返回添加到此模型的给定类型的所有侦听器的数组。StringgetName()获取样式的名称。AttributeSetgetResolveParent()从父级获取属性。booleanisDefined(Object attrName)检查是否定义了给定属性。booleanisEqual(AttributeSet attr)检查两个属性集是否相等。voidremoveAttribute(Object name)从集合中删除属性。voidremoveAttributes(Enumeration<?> names)删除元素的一组属性。voidremoveAttributes(AttributeSet attrs)删除元素的一组属性。voidremoveChangeListener(ChangeListener l)删除更改侦听器。voidsetName(String name)更改样式的名称。voidsetResolveParent(AttributeSet parent)设置解析父级。StringtoString()将样式转换为字符串。
-
-
-
字段详细信息
-
listenerList
protected EventListenerList listenerList
模型的更改侦听器。
-
changeEvent
protected transient ChangeEvent changeEvent
每个模型实例只需要一个ChangeEvent,因为事件的唯一(只读)状态是source属性。 这里生成的事件源始终是“this”。
-
-
方法详细信息
-
getName
public String getName()
获取样式的名称。 不需要命名样式,因此如果没有与样式关联的名称,则返回null。
-
setName
public void setName(String name)
更改样式的名称。 没有任何空名称。- 参数
-
name- 新名称
-
addChangeListener
public void addChangeListener(ChangeListener l)
添加更改侦听器。- Specified by:
-
addChangeListener接口Style - 参数
-
l- 更改侦听器
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
删除更改侦听器。- Specified by:
-
removeChangeListener在界面Style - 参数
-
l- 更改侦听器
-
getChangeListeners
public ChangeListener[] getChangeListeners()
返回使用addChangeListener()添加到此NamedStyle的所有ChangeListener的数组。- 结果
-
添加了所有
ChangeListener或如果没有添加侦听器则为空数组 - 从以下版本开始:
- 1.4
-
fireStateChanged
protected void fireStateChanged()
通知所有已注册对此事件类型的通知感兴趣的听众。 使用传递给fire方法的参数延迟创建事件实例。- 另请参见:
-
EventListenerList
-
getListeners
public <T extends EventListener> T[] getListeners(类<T> listenerType)
返回添加到此模型的给定类型的所有侦听器的数组。- 参数类型
-
T- 侦听器类型 - 参数
-
listenerType- 请求的侦听器类型 - 结果
- 从此模型接收 listenerType通知的所有对象
- 从以下版本开始:
- 1.3
-
getAttributeCount
public int getAttributeCount()
获取已定义的属性数。- Specified by:
-
getAttributeCount接口AttributeSet - 结果
- 属性数> = 0
- 另请参见:
-
AttributeSet.getAttributeCount()
-
isDefined
public boolean isDefined(Object attrName)
检查是否定义了给定属性。- Specified by:
-
isDefined接口AttributeSet - 参数
-
attrName- 非null属性名称 - 结果
- 如果定义了属性,则为true
- 另请参见:
-
AttributeSet.isDefined(java.lang.Object)
-
isEqual
public boolean isEqual(AttributeSet attr)
检查两个属性集是否相等。- Specified by:
-
isEqual接口AttributeSet - 参数
-
attr- 要检查的属性集 - 结果
- 如果相同则为真
- 另请参见:
-
AttributeSet.isEqual(javax.swing.text.AttributeSet)
-
copyAttributes
public AttributeSet copyAttributes()
复制一组属性。- Specified by:
-
copyAttributes接口AttributeSet - 结果
- 副本
- 另请参见:
-
AttributeSet.copyAttributes()
-
getAttribute
public Object getAttribute(Object attrName)
获取属性的值。- Specified by:
-
getAttribute接口AttributeSet - 参数
-
attrName- 非空属性名称 - 结果
- 属性值
- 另请参见:
-
AttributeSet.getAttribute(java.lang.Object)
-
getAttributeNames
public Enumeration<?> getAttributeNames()
获取所有属性的名称。- Specified by:
-
getAttributeNames接口AttributeSet - 结果
- 属性名称为枚举
- 另请参见:
-
AttributeSet.getAttributeNames()
-
containsAttribute
public boolean containsAttribute(Object name, Object value)
检查是否定义了给定的属性名称/值。- Specified by:
-
containsAttribute接口AttributeSet - 参数
-
name- 非null属性名称 -
value- 属性值 - 结果
- 如果定义了名称/值,则为true
- 另请参见:
-
AttributeSet.containsAttribute(java.lang.Object, java.lang.Object)
-
containsAttributes
public boolean containsAttributes(AttributeSet attrs)
检查元素是否包含所有属性。- Specified by:
-
containsAttributes接口AttributeSet - 参数
-
attrs- 要检查的属性 - 结果
- 如果元素包含所有属性,则为true
- 另请参见:
-
AttributeSet.containsAttributes(javax.swing.text.AttributeSet)
-
getResolveParent
public AttributeSet getResolveParent()
从父级获取属性。 如果未覆盖,则解析父级默认为父元素。- Specified by:
-
getResolveParent接口AttributeSet - 结果
- 来自父级的属性
- 另请参见:
-
AttributeSet.getResolveParent()
-
addAttribute
public void addAttribute(Object name, Object value)
添加属性。- Specified by:
-
addAttribute接口MutableAttributeSet - 参数
-
name- 非null属性名称 -
value- 属性值 - 另请参见:
-
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
-
addAttributes
public void addAttributes(AttributeSet attr)
向元素添加一组属性。- Specified by:
-
addAttributes接口MutableAttributeSet - 参数
-
attr- 要添加的属性 - 另请参见:
-
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)
-
removeAttribute
public void removeAttribute(Object name)
从集合中删除属性。- Specified by:
-
removeAttribute接口MutableAttributeSet - 参数
-
name- 非null属性名称 - 另请参见:
-
MutableAttributeSet.removeAttribute(java.lang.Object)
-
removeAttributes
public void removeAttributes(Enumeration<?> names)
删除元素的一组属性。- Specified by:
-
removeAttributes接口MutableAttributeSet - 参数
-
names- 属性名称 - 另请参见:
-
MutableAttributeSet.removeAttributes(java.util.Enumeration<?>)
-
removeAttributes
public void removeAttributes(AttributeSet attrs)
删除元素的一组属性。- Specified by:
-
removeAttributes接口MutableAttributeSet - 参数
-
attrs- 属性 - 另请参见:
-
MutableAttributeSet.removeAttributes(java.util.Enumeration<?>)
-
setResolveParent
public void setResolveParent(AttributeSet parent)
设置解析父级。- Specified by:
-
setResolveParent接口MutableAttributeSet - 参数
-
parent- 父级,如果没有parentnull - 另请参见:
-
MutableAttributeSet.setResolveParent(javax.swing.text.AttributeSet)
-
-