javax.swing.text
Class StyleContext.NamedStyle

java.lang.Object
  extended by javax.swing.text.StyleContext.NamedStyle
All Implemented Interfaces:
Serializable, AttributeSet, MutableAttributeSet, Style
Enclosing class:
StyleContext

public class StyleContext.NamedStyle
extends Object
implements Serializable, Style

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
 
Field Summary
protected  ChangeEvent changeEvent
           
protected  EventListenerList listenerList
           
 
Fields inherited from interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
 
Constructor Summary
StyleContext.NamedStyle()
           
StyleContext.NamedStyle(String name, Style parent)
           
StyleContext.NamedStyle(Style parent)
           
 
Method Summary
 void addAttribute(Object name, Object value)
          Adds an attribute with the given name and value to the set.
 void addAttributes(AttributeSet attr)
          Adds all the attributes from attributes to this set.
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener object to the style.
 boolean containsAttribute(Object name, Object value)
          Returns true if this AttributeSet contains an attribute with the specified name and value, false otherwise.
 boolean containsAttributes(AttributeSet attrs)
          Returns true of this AttributeSet contains all of the specified attributes.
 AttributeSet copyAttributes()
          Creates and returns a copy of this AttributeSet.
protected  void fireStateChanged()
           
 Object getAttribute(Object attrName)
          Returns the attribute with the specified key or null if no such attribute is defined in this AttributeSet and its resolving parents.
 int getAttributeCount()
          Returns the number of attributes that are stored locally in this AttributeSet.
 Enumeration<?> getAttributeNames()
          Returns the names of the attributes that are stored in this AttributeSet.
 ChangeListener[] getChangeListeners()
           
<T extends EventListener>
T[]
getListeners(Class<T> listenerType)
           
 String getName()
          Returns the name of the style.
 AttributeSet getResolveParent()
          Returns the resolving parent of this AttributeSet.
 boolean isDefined(Object attrName)
          Returns true if an attribute with the specified name is defined locally in this AttributeSet, without resolving through the resolving parents.
 boolean isEqual(AttributeSet attr)
          Returns true if all of the attributes in attr are equal to the attributes in this AttributeSet, false otherwise.
 void removeAttribute(Object name)
          Removes the attribute with the specified name, if this attribute is defined.
 void removeAttributes(AttributeSet attrs)
          Removes attributes from this set if they are found in the given set.
 void removeAttributes(Enumeration<?> names)
          Removes the attributes listed in names.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener from to the style.
 void setName(String n)
           
 void setResolveParent(AttributeSet parent)
          Sets the reolving parent for this set.
 String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

changeEvent

protected transient ChangeEvent changeEvent

listenerList

protected EventListenerList listenerList
Constructor Detail

StyleContext.NamedStyle

public StyleContext.NamedStyle()

StyleContext.NamedStyle

public StyleContext.NamedStyle(Style parent)

StyleContext.NamedStyle

public StyleContext.NamedStyle(String name,
                               Style parent)
Method Detail

getName

public String getName()
Description copied from interface: Style
Returns the name of the style.

Specified by:
getName in interface Style
Returns:
the name

setName

public void setName(String n)

addChangeListener

public void addChangeListener(ChangeListener l)
Description copied from interface: Style
Adds a ChangeListener object to the style.

Specified by:
addChangeListener in interface Style
Parameters:
l - the listener object to add

removeChangeListener

public void removeChangeListener(ChangeListener l)
Description copied from interface: Style
Removes a ChangeListener from to the style.

Specified by:
removeChangeListener in interface Style
Parameters:
l - the listener object to remove,

getListeners

public <T extends EventListener> T[] getListeners(Class<T> listenerType)

getChangeListeners

public ChangeListener[] getChangeListeners()

fireStateChanged

protected void fireStateChanged()

addAttribute

public void addAttribute(Object name,
                         Object value)
Description copied from interface: MutableAttributeSet
Adds an attribute with the given name and value to the set. If the set already contains an attribute with the given name, the attribute value is updated.

Specified by:
addAttribute in interface MutableAttributeSet
Parameters:
name - the attribute name (null not permitted).
value - the value (null not permitted).

addAttributes

public void addAttributes(AttributeSet attr)
Description copied from interface: MutableAttributeSet
Adds all the attributes from attributes to this set.

Specified by:
addAttributes in interface MutableAttributeSet
Parameters:
attr - the set of attributes to add (null not permitted).

containsAttribute

public boolean containsAttribute(Object name,
                                 Object value)
Description copied from interface: AttributeSet
Returns true if this AttributeSet contains an attribute with the specified name and value, false otherwise.

Specified by:
containsAttribute in interface AttributeSet
Parameters:
name - the name of the requested attribute
value - the value of the requested attribute
Returns:
true if this AttributeSet contains an attribute with the specified name and value, false otherwise

containsAttributes

public boolean containsAttributes(AttributeSet attrs)
Description copied from interface: AttributeSet
Returns true of this AttributeSet contains all of the specified attributes.

Specified by:
containsAttributes in interface AttributeSet
Parameters:
attrs - the requested attributes
Returns:
true of this AttributeSet contains all of the specified attributes

copyAttributes

public AttributeSet copyAttributes()
Description copied from interface: AttributeSet
Creates and returns a copy of this AttributeSet.

Specified by:
copyAttributes in interface AttributeSet
Returns:
a copy of this AttributeSet

getAttribute

public Object getAttribute(Object attrName)
Description copied from interface: AttributeSet
Returns the attribute with the specified key or null if no such attribute is defined in this AttributeSet and its resolving parents.

Specified by:
getAttribute in interface AttributeSet
Parameters:
attrName - the key of the attribute that is looked up
Returns:
the attribute with the specified key or null if no such attribute is defined in this AttributeSet and its resolving parents

getAttributeCount

public int getAttributeCount()
Description copied from interface: AttributeSet
Returns the number of attributes that are stored locally in this AttributeSet.

Specified by:
getAttributeCount in interface AttributeSet
Returns:
the number of attributes that are stored locally in this AttributeSet

getAttributeNames

public Enumeration<?> getAttributeNames()
Description copied from interface: AttributeSet
Returns the names of the attributes that are stored in this AttributeSet.

Specified by:
getAttributeNames in interface AttributeSet
Returns:
the names of the attributes that are stored in this AttributeSet

isDefined

public boolean isDefined(Object attrName)
Description copied from interface: AttributeSet
Returns true if an attribute with the specified name is defined locally in this AttributeSet, without resolving through the resolving parents.

Specified by:
isDefined in interface AttributeSet
Returns:
true if an attribute with the specified name is defined locally in this AttributeSet

isEqual

public boolean isEqual(AttributeSet attr)
Description copied from interface: AttributeSet
Returns true if all of the attributes in attr are equal to the attributes in this AttributeSet, false otherwise.

Specified by:
isEqual in interface AttributeSet
Parameters:
attr - the attributes to be compared to this
Returns:
true if all of the attributes in attr are equal to the attributes in this AttributeSet, false otherwise

removeAttribute

public void removeAttribute(Object name)
Description copied from interface: MutableAttributeSet
Removes the attribute with the specified name, if this attribute is defined. This method will only remove an attribute from this set, not from the resolving parent.

Specified by:
removeAttribute in interface MutableAttributeSet
Parameters:
name - the attribute name (null not permitted).

removeAttributes

public void removeAttributes(AttributeSet attrs)
Description copied from interface: MutableAttributeSet
Removes attributes from this set if they are found in the given set. Only attributes whose key AND value are removed. Removes attributes only from this set, not from the resolving parent. Since the resolving parent is stored as an attribute, if attributes has the same resolving parent as this set, the parent will be removed from this set.

Specified by:
removeAttributes in interface MutableAttributeSet
Parameters:
attrs - the attributes (null not permitted).

removeAttributes

public void removeAttributes(Enumeration<?> names)
Description copied from interface: MutableAttributeSet
Removes the attributes listed in names.

Specified by:
removeAttributes in interface MutableAttributeSet
Parameters:
names - the attribute names (null not permitted).

getResolveParent

public AttributeSet getResolveParent()
Description copied from interface: AttributeSet
Returns the resolving parent of this AttributeSet. If a key is not stored locally, then a AttributeSet.getAttribute(Object) request is resolved up in the resolving parent of this AttributeSet.

Specified by:
getResolveParent in interface AttributeSet
Returns:
the resolving parent of this AttributeSet

setResolveParent

public void setResolveParent(AttributeSet parent)
Description copied from interface: MutableAttributeSet
Sets the reolving parent for this set. When looking up an attribute, if it is not found in this set, then the resolving parent is also used for the lookup.

Specified by:
setResolveParent in interface MutableAttributeSet
Parameters:
parent - the parent attribute set (null not permitted).

toString

public String toString()
Description copied from class: Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() and such.

It is typical, but not required, to ensure that this method never completes abruptly with a RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).

Overrides:
toString in class Object
Returns:
the String representing this Object, which may be null
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)