This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.text
class StyleContext.NamedStyle

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

public class StyleContext.NamedStyle
extends Object
implements Style, Serializable

A collection of attributes, typically used to represent character and paragraph styles. This is an implementation of MutableAttributeSet that can be observed if desired. These styles will take advantage of immutability while the sets are small enough, and may be substantially more efficient than something like SimpleAttributeSet.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.


Field Summary
protected transient ChangeEvent changeEvent
          Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property.
protected EventListenerList listenerList
          The change listeners for the model.
 
Constructor Summary

          Creates a new named style, with a null name and parent.

          Creates a new named style.

          Creates a new named style.
 
Method Summary
 void
addAttribute(Object name, Object value)

          Adds an attribute.
 void

          Adds a set of attributes to the element.
 void

          Adds a change listener.
 boolean

          Checks whether a given attribute name/value is defined.
 boolean

          Checks whether the element contains all the attributes.
 AttributeSet

          Copies a set of attributes.
protected void

          Notifies all listeners that have registered interest for notification on this event type.
 Object
getAttribute(Object attrName)

          Gets the value of an attribute.
 int

          Gets the number of attributes that are defined.
 Enumeration

          Gets the names of all attributes.
 ChangeListener[]

          Returns an array of all the ChangeListeners added to this NamedStyle with addChangeListener().
 EventListener[]
getListeners(Class listenerType)

          Return an array of all the listeners of the given type that were added to this model.
 String

          Fetches the name of the style.
 AttributeSet

          Gets attributes from the parent.
 boolean
isDefined(Object attrName)

          Checks whether a given attribute is defined.
 boolean

          Checks whether two attribute sets are equal.
 void

          Removes an attribute from the set.
 void

          Removes a set of attributes for the element.
 void

          Removes a set of attributes for the element.
 void

          Removes a change listener.
 void

          Changes the name of the style.
 void

          Sets the resolving parent.
 String

          Converts the style to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeEvent

protected transient ChangeEvent changeEvent
Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".

listenerList

protected EventListenerList listenerList
The change listeners for the model.
Constructor Detail

StyleContext.NamedStyle

public StyleContext.NamedStyle()
Creates a new named style, with a null name and parent.


StyleContext.NamedStyle

public StyleContext.NamedStyle(String name,
                               Style parent)
Creates a new named style.

Parameters:
name - the style name, null for unnamed
parent - the parent style, null if none

StyleContext.NamedStyle

public StyleContext.NamedStyle(Style parent)
Creates a new named style.

Parameters:
parent - the parent style, null if none
Method Detail

addAttribute

public void addAttribute(Object name,
                         Object value)
Adds an attribute.

Parameters:
name - the non-null attribute name
value - the attribute value

addAttributes

public void addAttributes(AttributeSet attr)
Adds a set of attributes to the element.

Parameters:
attr - the attributes to add

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a change listener.

Parameters:
l - the change listener

containsAttribute

public boolean containsAttribute(Object name,
                                 Object value)
Checks whether a given attribute name/value is defined.

Parameters:
name - the non-null attribute name
value - the attribute value
Returns:
true if the name/value is defined

containsAttributes

public boolean containsAttributes(AttributeSet attrs)
Checks whether the element contains all the attributes.

Parameters:
attrs - the attributes to check
Returns:
true if the element contains all the attributes

copyAttributes

public AttributeSet copyAttributes()
Copies a set of attributes.

Returns:
the copy

fireStateChanged

protected void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.


getAttribute

public Object getAttribute(Object attrName)
Gets the value of an attribute.

Parameters:
attrName - the non-null attribute name
Returns:
the attribute value

getAttributeCount

public int getAttributeCount()
Gets the number of attributes that are defined.

Returns:
the number of attributes >= 0

getAttributeNames

public Enumeration getAttributeNames()
Gets the names of all attributes.

Returns:
the attribute names as an enumeration

getChangeListeners

public ChangeListener[] getChangeListeners()
Returns an array of all the ChangeListeners added to this NamedStyle with addChangeListener().

Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

getListeners

public EventListener[] getListeners(Class listenerType)
Return an array of all the listeners of the given type that were added to this model.

Parameters:
listenerType
Returns:
all of the objects receiving listenerType notifications from this model

getName

public String getName()
Fetches the name of the style. A style is not required to be named, so null is returned if there is no name associated with the style.

Returns:
the name

getResolveParent

public AttributeSet getResolveParent()
Gets attributes from the parent. If not overriden, the resolving parent defaults to the parent element.

Returns:
the attributes from the parent

isDefined

public boolean isDefined(Object attrName)
Checks whether a given attribute is defined.

Parameters:
attrName - the non-null attribute name
Returns:
true if the attribute is defined

isEqual

public boolean isEqual(AttributeSet attr)
Checks whether two attribute sets are equal.

Parameters:
attr - the attribute set to check against
Returns:
true if the same

removeAttribute

public void removeAttribute(Object name)
Removes an attribute from the set.

Parameters:
name - the non-null attribute name

removeAttributes

public void removeAttributes(AttributeSet attrs)
Removes a set of attributes for the element.

Parameters:
attrs - the attributes

removeAttributes

public void removeAttributes(Enumeration names)
Removes a set of attributes for the element.

Parameters:
names - the attribute names

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a change listener.

Parameters:
l - the change listener

setName

public void setName(String name)
Changes the name of the style. Does nothing with a null name.

Parameters:
name - the new name

setResolveParent

public void setResolveParent(AttributeSet parent)
Sets the resolving parent.

Parameters:
parent - the parent, null if none

toString

public String toString()
Converts the style to a string.

Overrides:
toString in class Object
Returns:
the string


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.