所有类


javax.swing.text
类 StyleContext.NamedStyle

java.lang.Object
  继承者 javax.swing.text.StyleContext.NamedStyle
所有已实现的接口:
Serializable, AttributeSet, MutableAttributeSet, Style
正在封闭类:
StyleContext

public class StyleContext.NamedStyle
   
   
   
   
extends Object
implements Style, Serializable

通常用于表示字符和段落样式的属性集合。这是 MutableAttributeSet(在需要时可以观察它)的一个实现。当集合足够小时这些样式将利用不可变性的优势,并且可能比诸如 SimpleAttributeSet 之类更为高效。

警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder


嵌套类摘要
 
从接口 javax.swing.text.AttributeSet 继承的嵌套类/接口
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
 
字段摘要
protected  ChangeEventchangeEvent
          由于事件的惟一状态(只读)为源属性,因此每个模型实例只需要一个 ChangeEvent。
protected  EventListenerListlistenerList
          模型的更改侦听器。
 
从接口 javax.swing.text.AttributeSet 继承的字段
NameAttribute, ResolveAttribute
 
构造方法摘要
StyleContext.NamedStyle()
          利用 null 名称和父级创建新的命名样式。
StyleContext.NamedStyle(String name, Style parent)
          创建新的命名样式。
StyleContext.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(Class<T> listenerType)
          返回具有添加到此模型中的给定类型的所有侦听器组成的数组。
 StringgetName()
          获取样式的名称。
 AttributeSetgetResolveParent()
          从父级获取属性。
 booleanisDefined(Object attrName)
          确定给定属性是否已定义。
 booleanisEqual(AttributeSet attr)
          检查两个属性集是否相等。
 voidremoveAttribute(Object name)
          从集合中移除属性。
 voidremoveAttributes(AttributeSet attrs)
          移除元素的属性集。
 voidremoveAttributes(Enumeration<?> names)
          移除元素的属性集。
 voidremoveChangeListener(ChangeListener l)
          移除更改侦听器。
 voidsetName(String name)
          更改样式的名称。
 voidsetResolveParent(AttributeSet parent)
          设置解析的父级。
 StringtoString()
          将样式转换成为字符串。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

listenerList

protected EventListenerList listenerList
模型的更改侦听器。


changeEvent

protected transient ChangeEvent changeEvent
由于事件的惟一状态(只读)为源属性,因此每个模型实例只需要一个 ChangeEvent。此处生成的事件源总是 "this"。

构造方法详细信息

StyleContext.NamedStyle

public StyleContext.NamedStyle(String name,
                               Style parent)
创建新的命名样式。

参数:
name - 样式名称,未命名则为 null
parent - 父样式,如果没有则为 null

StyleContext.NamedStyle

public StyleContext.NamedStyle(Style parent)
创建新的命名样式。

参数:
parent - 父样式,如果没有则为 null

StyleContext.NamedStyle

public StyleContext.NamedStyle()
利用 null 名称和父级创建新的命名样式。

方法详细信息

toString

public String toString()
将样式转换成为字符串。

覆盖:
Object 中的 toString
返回:
字符串

getName

public String getName()
获取样式的名称。样式不是必须命名的,因此如果没有与该样式关联的名称,则返回 null。

指定者:
接口 Style 中的 getName
返回:
名称

setName

public void setName(String name)
更改样式的名称。利用 null 名称不能执行任何操作。

参数:
name - 新名称

addChangeListener

public void addChangeListener(ChangeListener l)
添加更改侦听器。

指定者:
接口 Style 中的 addChangeListener
参数:
l - 更改侦听器